/**
 * 便签组件样式
 *   icon 卡片 与 详情面板 共用同一套视觉语言：
 *     - 主体奶油暖底 + 右上主题色光晕；
 *     - 列表项是\"小便签卡片\"：圆角 + 微阴影 + 左侧彩色色条 + 标题/摘要；
 *     - 主题色 --note-color 由 JS 按当前置顶/选中便签注入。
 *   1×1：halotab-app.js 的 mini 渲染器复用 .halotab-widget-note 类，由
 *     halotab.css 里 mini 重置布局，本文件无需特殊处理。
 *   暗色模式下统一压暗背景、提亮文字。
 */

/* ============================================================
 * 桌面卡片（2×2 / 4×2 共用）
 * ============================================================ */
.halotab-widget-note {
  --note-color: #eab308;
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 12px 12px 10px;
  gap: 8px;
  box-sizing: border-box;
  color: #1f2937;
  background:
    radial-gradient(120% 80% at 100% 0%, color-mix(in srgb, var(--note-color) 14%, transparent) 0%, transparent 60%),
    linear-gradient(160deg, #fffdf6 0%, #fff7e0 100%);
  border-radius: inherit;
  cursor: pointer;
  overflow: hidden;
}

/* 装饰层：右上主题色光晕（fill="currentColor" 跟随 --note-color） */
.halotab-widget-note .halotab-widget-deco-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: var(--note-color);
  z-index: 0;
}
.halotab-widget-note .halotab-widget-deco-bg svg {
  width: 100%; height: 100%; display: block;
}

/* head / body / empty 全部抬到装饰层之上 */
.halotab-widget-note-head,
.halotab-widget-note-body,
.halotab-widget-note-empty { position: relative; z-index: 1; }

/* ---- 顶部标题栏 ---- */
.halotab-widget-note-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  font-size: clamp(12px, 3.6cqi, 14px);
  font-weight: 700;
  color: #1f2937;
  line-height: 1.2;
  padding: 0 2px;
}
.halotab-widget-note-head-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--note-color) 18%, #fff);
  color: var(--note-color);
}
.halotab-widget-note-head-ico svg { display: block; }
.halotab-widget-note-head-title {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: .3px;
}
.halotab-widget-note-head-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--note-color) 16%, #fff);
  color: color-mix(in srgb, var(--note-color) 70%, #1f2937);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* ---- 便签条目列表 ---- */
.halotab-widget-note-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 5px;
  overflow: hidden;
}
.halotab-widget-note-row {
  --note-row-color: var(--note-color);
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 14px;
  min-width: 0;
  font-size: clamp(11px, 3.4cqi, 13px);
  line-height: 1.4;
  color: #1f2937;
  background: rgba(255, 255, 255, .65);
  /* 边框跟随便签色（与左侧色条配色统一） */
  border: 1px solid color-mix(in srgb, var(--note-row-color) 18%, transparent);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(120, 87, 18, .04);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* 抵消 .halotab-card 的 text-align:center 继承，便签内容统一左对齐 */
  text-align: left;
  transition: background .15s ease, border-color .15s ease;
}
/* 左侧彩色短条（便签条颜色） */
.halotab-widget-note-row::before {
  content: "";
  position: absolute;
  left: 4px; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: 2px;
  background: var(--note-row-color);
  transition: width .15s ease;
}
.halotab-widget-note-row-text {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  text-align: left;
}
/* 无标题（取自正文首行）—— 斜体 + 颜色更浅，提示"这是片段" */
.halotab-widget-note-row[data-untitled="true"] .halotab-widget-note-row-text {
  font-style: italic;
  font-weight: 400;
  color: #6b7280;
}
.halotab-widget-note-row[data-pinned="true"] {
  background: color-mix(in srgb, var(--note-row-color) 10%, #fff);
  border-color: color-mix(in srgb, var(--note-row-color) 32%, transparent);
}
.halotab-widget-note-row[data-pinned="true"] .halotab-widget-note-row-text::before {
  content: "📌";
  font-size: .85em;
  margin-right: 4px;
  vertical-align: -1px;
}

/* ---- 空态 ---- */
.halotab-widget-note-empty {
  display: none;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 8px;
  color: color-mix(in srgb, var(--note-color) 70%, #64748b);
}
.halotab-widget-note.is-empty .halotab-widget-note-body { display: none; }
.halotab-widget-note.is-empty .halotab-widget-note-empty { display: flex; }
.halotab-widget-note-empty-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--note-color) 14%, #fff);
  color: var(--note-color);
}
.halotab-widget-note-empty-tip {
  font-size: clamp(11px, 3.2cqi, 12px);
  color: #94a3b8;
  text-align: center;
}

/* ---- 暗色模式（卡片） ---- */
html[data-theme="dark"] .halotab-widget-note,
html[data-theme="auto"] .halotab-widget-note {
  background:
    radial-gradient(120% 80% at 100% 0%, color-mix(in srgb, var(--note-color) 28%, transparent) 0%, transparent 60%),
    linear-gradient(160deg, #2a2410 0%, #1f1a0c 100%);
  color: #f1f5f9;
}
html[data-theme="dark"] .halotab-widget-note-head,
html[data-theme="auto"] .halotab-widget-note-head { color: #f1f5f9; }
html[data-theme="dark"] .halotab-widget-note-head-ico,
html[data-theme="auto"] .halotab-widget-note-head-ico {
  background: color-mix(in srgb, var(--note-color) 28%, #0f172a);
}
html[data-theme="dark"] .halotab-widget-note-head-count,
html[data-theme="auto"] .halotab-widget-note-head-count {
  background: color-mix(in srgb, var(--note-color) 24%, #0f172a);
  color: color-mix(in srgb, var(--note-color) 90%, #fff);
}
html[data-theme="dark"] .halotab-widget-note-row,
html[data-theme="auto"] .halotab-widget-note-row {
  background: rgba(255, 255, 255, .04);
  border-color: rgba(234, 179, 8, .18);
  color: #f1f5f9;
  box-shadow: none;
}
html[data-theme="dark"] .halotab-widget-note-row[data-pinned="true"],
html[data-theme="auto"] .halotab-widget-note-row[data-pinned="true"] {
  background: color-mix(in srgb, var(--note-row-color) 18%, #0f172a);
  border-color: color-mix(in srgb, var(--note-row-color) 40%, transparent);
}
html[data-theme="dark"] .halotab-widget-note-empty-tip,
html[data-theme="auto"] .halotab-widget-note-empty-tip { color: #94a3b8; }


/* ============================================================
 * 详情面板（appBox 内）—— 与 icon 共用奶油暖底
 * ============================================================ */
.ht-appbox-body[data-key="note"] { padding: 0; height: 100%; }

.ht-note-app {
  --note-color: #eab308;
  --note-text: #1f2937;
  --note-text-soft: #64748b;
  --note-bg: #fffaeb;          /* 与 icon 同系奶油底 */
  --note-side-bg: #fffdf6;     /* 左列侧栏稍微更亮 */
  --note-card-bg: #ffffff;     /* 列表项 / 输入区卡片底 */
  --note-border: #f1e3b8;      /* 暖系米色描边 */
  --note-border-soft: rgba(234, 179, 8, .14);
  display: grid;
  grid-template-columns: 320px 1fr;
  width: 100%;
  height: 100%;
  background: var(--note-bg);
  color: var(--note-text);
  font-size: 14px;
  overflow: hidden;
}

/* ---------- 左列 ---------- */
.ht-note-side {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--note-border);
  background: var(--note-side-bg);
  min-height: 0;
}
.ht-note-side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--note-border);
  flex: 0 0 auto;
}
.ht-note-side-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--note-text);
  letter-spacing: .3px;
}
.ht-note-side-add {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #eab308, #f97316);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(234, 179, 8, .28);
  transition: filter .15s, transform .15s, box-shadow .15s;
}
.ht-note-side-add:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(234, 179, 8, .35);
}

.ht-note-search {
  position: relative;
  padding: 10px 12px;
  border-bottom: 1px solid var(--note-border);
  flex: 0 0 auto;
}
.ht-note-search-ico {
  position: absolute;
  left: 22px; top: 50%;
  transform: translateY(-50%);
  color: var(--note-text-soft);
  pointer-events: none;
}
.ht-note-search-input {
  width: 100%;
  height: 32px;
  padding: 0 10px 0 30px;
  border: 1px solid var(--note-border);
  border-radius: 8px;
  background: var(--note-card-bg);
  color: var(--note-text);
  font-size: 13px;
  box-sizing: border-box;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.ht-note-search-input:focus {
  outline: none;
  border-color: var(--note-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--note-color) 18%, transparent);
}

.ht-note-list {
  list-style: none;
  margin: 0;
  padding: 10px;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  /* 暖色系自定义滚动条，与奶油底协调 */
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--note-color) 28%, transparent) transparent;
}
.ht-note-list::-webkit-scrollbar { width: 8px; }
.ht-note-list::-webkit-scrollbar-track { background: transparent; }
.ht-note-list::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--note-color) 22%, transparent);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.ht-note-list::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--note-color) 38%, transparent);
  background-clip: padding-box;
  border: 2px solid transparent;
}
.ht-note-list-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 30px 16px;
  color: var(--note-text-soft);
  font-size: 13px;
  text-align: center;
}
.ht-note-list-empty span:first-child { font-size: 28px; }

/* 列表项：卡片化 —— 顶部标题行 + 摘要 + 时间右下角 */
.ht-note-list-item {
  --note-item-color: #94a3b8;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px 10px 16px;
  margin-bottom: 8px;
  border-radius: 10px;
  border: 1px solid var(--note-border-soft);
  background: var(--note-card-bg);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease;
  overflow: hidden;
}
/* 左侧彩色色条 —— 默认半高，hover/active 全高加粗（Mail.app 风） */
.ht-note-list-item::before {
  content: "";
  position: absolute;
  left: 0; top: 10px; bottom: 10px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--note-item-color);
  transition: width .15s ease, top .15s ease, bottom .15s ease;
}
.ht-note-list-item:hover {
  border-color: color-mix(in srgb, var(--note-item-color) 35%, var(--note-border-soft));
  box-shadow: 0 4px 12px rgba(120, 87, 18, .08);
  transform: translateY(-1px);
}
.ht-note-list-item:hover::before { top: 4px; bottom: 4px; width: 4px; }
.ht-note-list-item.is-active {
  background: color-mix(in srgb, var(--note-item-color) 10%, var(--note-card-bg));
  border-color: color-mix(in srgb, var(--note-item-color) 50%, transparent);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--note-item-color) 22%, transparent);
}
/* 选中态：左侧色条贯穿整张卡片，加粗到 5px —— 强信号 */
.ht-note-list-item.is-active::before {
  width: 5px;
  top: 0; bottom: 0;
  border-radius: 0 3px 3px 0;
}
.ht-note-list-item-title {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--note-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
/* 无标题：隐藏标题行，让预览有更多发挥空间（3 行） */
.ht-note-list-item[data-untitled="true"] .ht-note-list-item-title { display: none; }
.ht-note-list-item[data-untitled="true"] .ht-note-list-item-preview {
  -webkit-line-clamp: 3;
  font-size: 13px;
  color: var(--note-text);
}
.ht-note-list-item-title .ht-note-list-pin {
  flex: 0 0 auto;
  color: var(--note-item-color);
}
.ht-note-list-item-title .ht-note-list-titletext {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 0;
  min-width: 0;
}
.ht-note-list-item-preview {
  font-size: 12px;
  color: var(--note-text-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}
/* 列表项底部 meta 行：时间 + 字数标签 */
.ht-note-list-item-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 2px;
  font-size: 11px;
  color: var(--note-text-soft);
  opacity: .85;
}
.ht-note-list-item-time { font-size: 11px; }
.ht-note-list-item-count {
  font-size: 11px;
  color: var(--note-text-soft);
  opacity: .75;
}
.ht-note-list-item-meta-dot { opacity: .5; }

/* ---------- 右列 ---------- */
.ht-note-main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--note-bg);
}
.ht-note-stage {
  flex: 1 1 auto;
  min-height: 0;
  padding: 22px 28px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* 空态 */
.ht-note-stage-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
  text-align: center;
  color: var(--note-text-soft);
}
.ht-note-stage[data-empty="true"] .ht-note-stage-empty { display: flex; }
.ht-note-stage[data-empty="true"] .ht-note-stage-edit { display: none; }
.ht-note-stage-empty-ico { font-size: 56px; }
.ht-note-stage-empty-title { font-size: 18px; font-weight: 700; color: var(--note-text); }
.ht-note-stage-empty-tip { font-size: 13px; }
.ht-note-stage-empty-btn {
  margin-top: 8px;
  padding: 8px 22px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #eab308, #f97316);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(234, 179, 8, .28);
  transition: filter .15s, transform .15s;
}
.ht-note-stage-empty-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }

/* 编辑态 */
.ht-note-stage-edit {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  min-height: 0;
}
.ht-note-stage[data-empty="false"] .ht-note-stage-edit { display: flex; }

.ht-note-stage-tagrow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.ht-note-stage-spacer { flex: 1; }
.ht-note-stage-status {
  font-size: 12px;
  color: var(--note-text-soft);
  min-width: 56px;
  text-align: right;
  transition: color .2s, opacity .3s;
}
.ht-note-stage-status[data-state="saving"] { color: var(--note-color); }
.ht-note-stage-status[data-state="saved"]  { color: #22c55e; opacity: 0; }
.ht-note-stage-status[data-state="saving"],
.ht-note-stage-status:not([data-state="saved"]) { opacity: 1; }
.ht-note-stage-act {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--note-border);
  border-radius: 8px;
  background: var(--note-card-bg);
  color: var(--note-text);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.ht-note-stage-act:hover {
  background: color-mix(in srgb, var(--note-color) 10%, #fff);
  border-color: color-mix(in srgb, var(--note-color) 35%, var(--note-border));
}
.ht-note-stage-del:hover { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }

.ht-note-stage-colors {
  display: flex;
  gap: 6px;
}
.ht-note-stage-color {
  --c: #eab308;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--c);
  cursor: pointer;
  transition: box-shadow .12s, transform .12s ease;
  border: 2px solid transparent;
}
.ht-note-stage-color:active { transform: scale(.88); }
.ht-note-stage-color.is-active {
  border-color: var(--c);
  box-shadow: 0 0 0 2px #fff inset, 0 0 0 3px var(--c);
}

.ht-note-stage-title {
  width: 100%;
  border: 0;
  outline: none;
  padding: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--note-text);
  background: transparent;
  font-family: inherit;
  line-height: 1.4;
  border-bottom: 2px solid transparent;
  transition: border-color .15s;
}
.ht-note-stage-title:focus {
  border-bottom-color: color-mix(in srgb, var(--note-color) 60%, transparent);
}

.ht-note-stage-body {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  border: 1px solid var(--note-border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--note-text);
  background: var(--note-card-bg);
  font-family: inherit;
  resize: none;
  box-sizing: border-box;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.ht-note-stage-body:focus {
  border-color: var(--note-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--note-color) 18%, transparent);
}

.ht-note-stage-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--note-text-soft);
  flex: 0 0 auto;
}
.ht-note-stage-foot-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ht-note-stage-foot-dot { opacity: .6; }

/* ---------- 暗色：详情面板 ---------- */
html[data-theme="dark"] .ht-note-app,
html[data-theme="auto"] .ht-note-app {
  --note-text: #e5e7eb;
  --note-text-soft: #94a3b8;
  --note-bg: #1f1a0c;
  --note-side-bg: #2a2410;
  --note-card-bg: #1e293b;
  --note-border: rgba(234, 179, 8, .22);
  --note-border-soft: rgba(234, 179, 8, .14);
}
html[data-theme="dark"] .ht-note-search-input,
html[data-theme="auto"] .ht-note-search-input {
  background: #0f172a;
  color: #e5e7eb;
}
html[data-theme="dark"] .ht-note-stage-body,
html[data-theme="auto"] .ht-note-stage-body {
  background: #0f172a;
  color: #e5e7eb;
}
html[data-theme="dark"] .ht-note-stage-act:hover,
html[data-theme="auto"] .ht-note-stage-act:hover {
  background: color-mix(in srgb, var(--note-color) 18%, #0f172a);
}
html[data-theme="dark"] .ht-note-list-item,
html[data-theme="auto"] .ht-note-list-item { background: #0f172a; }
html[data-theme="dark"] .ht-note-list-item.is-active,
html[data-theme="auto"] .ht-note-list-item.is-active {
  background: color-mix(in srgb, var(--note-item-color) 18%, #0f172a);
}

/* ---------- 窄屏：左列折叠为顶部条 ---------- */
@media (max-width: 720px) {
  .ht-note-app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .ht-note-side {
    border-right: 0;
    border-bottom: 1px solid var(--note-border);
    max-height: 38%;
  }
  .ht-note-stage { padding: 16px 18px; }
  .ht-note-stage-title { font-size: 20px; }
}
