/* ClipNote 手機版 */
:root {
  --accent: #2f7d5b;
  --accent-dark: #22603f;
  --bg: #ffffff;
  --bg2: #f4f5f3;
  --line: #e3e5e1;
  --text: #1f2421;
  --muted: #6d756f;
  --danger: #c0392b;
  --warn-bg: #fff6e0;
  --rec: #d63b3b;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px; line-height: 1.6; color: var(--text); background: var(--bg);
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--danger); }
.grow { flex: 1; }
.center { display: flex; justify-content: center; padding: 30px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line);
  text-decoration: none; color: var(--text); font-weight: 600;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.big { padding: 14px 24px; font-size: 17px; }
.btn:disabled { opacity: .5; }
.text-btn { color: var(--accent); font-weight: 600; padding: 6px 8px; }
.text-btn.light { color: #fff; opacity: .85; }

.spinner {
  width: 28px; height: 28px; border: 3px solid #d6e5dc; border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; display: inline-block;
}
.spinner.sm { width: 14px; height: 14px; border-width: 2px; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

.center-screen {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; gap: 8px;
}
.login-logo { width: 84px; height: 84px; border-radius: 20px; }
.center-screen h1 { margin: 8px 0 0; font-size: 22px; }

/* ---- 頂端列 ---- */
.bar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 4px;
  padding: calc(var(--safe-top) + 6px) 8px 6px; background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.bar h1 { flex: 1; font-size: 18px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { width: 40px; height: 40px; font-size: 22px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; }
.icon:active { background: var(--bg2); }
.chip {
  max-width: 55vw; padding: 4px 12px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line);
  font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.searchbox { padding: 8px 12px; background: var(--bg); }
.searchbox input {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2);
  font-size: 16px; -webkit-appearance: none; appearance: none;
}
.notice { padding: 8px 14px; font-size: 13px; background: #eaf4ee; color: var(--accent-dark); }
.notice.warn { background: var(--warn-bg); color: #7a5a00; }
.notice button { color: var(--accent); font-weight: 600; margin-left: 6px; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); }

/* ---- 清單 ---- */
#list { list-style: none; margin: 0; padding: 0 0 calc(110px + var(--safe-bottom)); }
#list li { padding: 11px 16px; border-bottom: 1px solid var(--line); }
#list li:active { background: var(--bg2); }
.li-title { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.li-sub { font-size: 12px; color: var(--muted); display: flex; gap: 8px; margin-top: 2px; white-space: nowrap; overflow: hidden; }
.li-sub .path { overflow: hidden; text-overflow: ellipsis; }
.li-snip { font-size: 13px; color: #4b544e; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.li-more { text-align: center; color: var(--muted); font-size: 13px; padding: 14px; border: 0 !important; }

.fabs {
  position: fixed; right: 16px; bottom: calc(18px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 14px; z-index: 20;
}
.fab {
  width: 58px; height: 58px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 30px;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center;
}
.fab.rec { background: #fff; color: var(--rec); font-size: 26px; border: 2px solid var(--rec); }
.fab:active { transform: scale(.94); }

/* ---- 分類抽屜 ---- */
#drawer { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.35); }
.drawer-panel {
  position: absolute; left: 0; top: 0; bottom: 0; width: min(84vw, 360px); background: var(--bg);
  overflow-y: auto; padding: calc(var(--safe-top) + 10px) 0 calc(20px + var(--safe-bottom));
  box-shadow: 4px 0 20px rgba(0,0,0,.2); animation: slidein .18s ease-out;
}
@keyframes slidein { from { transform: translateX(-30px); opacity: .3; } }
.drawer-head { font-weight: 700; padding: 6px 18px 10px; color: var(--muted); font-size: 13px; }
.cat-row { display: flex; align-items: center; min-height: 44px; padding-right: 12px; }
.cat-row.sel { background: #e7f2ec; }
.cat-row .tw { width: 34px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.cat-row .nm { flex: 1; padding: 8px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row .ct { color: var(--muted); font-size: 12px; margin-left: 6px; }
.cat-sep { height: 1px; background: var(--line); margin: 6px 0; }

/* ---- 筆記 ---- */
#note { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); z-index: 30; }
#n-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 16px 30px; }
#n-title {
  width: 100%; border: 0; font-size: 21px; font-weight: 700; padding: 4px 0; outline: none; background: transparent;
}
#n-title:not([readonly]) { border-bottom: 1px dashed var(--line); }
#n-info { margin-bottom: 10px; }
#n-clip { flex: 1; width: 100%; border: 0; background: #fff; }
#n-tools {
  display: flex; border-top: 1px solid var(--line); background: #fbfbfa; padding-bottom: var(--safe-bottom);
}
#n-tools button { flex: 1; padding: 7px 0 8px; font-size: 12px; display: flex; flex-direction: column; align-items: center; color: #3c4540; }
#n-tools button span { font-size: 22px; line-height: 1.2; }
#n-tools button:active { background: var(--bg2); }
#n-tools button:disabled { opacity: .4; }

.doc { outline: none; word-wrap: break-word; overflow-wrap: anywhere; min-height: 40vh; }
.doc.editing { min-height: 50vh; }
.doc img { max-width: 100%; height: auto; }
.doc table { max-width: 100%; display: block; overflow-x: auto; }
.doc pre { white-space: pre-wrap; }
.doc p { margin: 6px 0; }
.doc h1 { font-size: 20px; } .doc h2 { font-size: 18px; } .doc h3 { font-size: 16px; }
.doc blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--line); color: #4b544e; }

/* 附件 */
figure.att { margin: 10px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fafafa; }
.att-bar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; font-size: 13px; }
.att-bar .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-bar .sz { color: var(--muted); font-size: 12px; }
.att-bar button { color: var(--accent); font-weight: 600; padding: 4px 6px; }
.att-bar button.del { color: var(--danger); }
figure.att img { display: block; width: 100%; height: auto; min-height: 60px; background: #eee; }
figure.att audio { display: block; width: 100%; padding: 0 8px 8px; }
figure.att video { display: block; width: 100%; background: #000; }
.att-load { display: block; width: 100%; padding: 12px; color: var(--accent); font-weight: 600; border-top: 1px solid var(--line); }

/* 逐字稿、AI 整理（和電腦版相同的樣式） */
.transcript { margin: 4px 0 18px; padding: 4px 12px 10px; border-left: 4px solid #8fb8dc; background: #f6f9fc; border-radius: 0 8px 8px 0; }
.transcript p { margin: 6px 0; }
.tr-head, .ai-head { font-size: 12px; padding: 6px 0; margin-bottom: 6px; -webkit-user-select: none; user-select: none; }
.tr-head { color: #5b7a94; border-bottom: 1px solid #e1e9f1; }
.transcript .ts { color: #7a95ad; font-size: 12px; font-family: Menlo, Consolas, monospace; }
.transcript b.spk { color: #2a5d86; }
.transcript .scene { color: #6b7d4f; }
.ai-sum { margin: 4px 0 18px; padding: 4px 12px 10px; border-left: 4px solid #c9a7e8; background: #faf6fd; border-radius: 0 8px 8px 0; }
.ai-sum p { margin: 6px 0; }
.ai-sum h3 { font-size: 16px; margin: 12px 0 4px; color: #5b2f80; }
.ai-head { color: #8a6aa8; border-bottom: 1px solid #eadcf5; }

/* ---- 錄音中 ---- */
#recording {
  position: fixed; inset: 0; z-index: 60; background: #1d2320; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 24px 24px calc(24px + var(--safe-bottom));
}
#recording .muted { color: #b6c0ba; text-align: center; font-size: 14px; }
.rec-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--rec); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
#rec-time { font-size: 56px; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: 2px; }
.rec-stop {
  width: 84px; height: 84px; border-radius: 50%; background: var(--rec); color: #fff; font-size: 30px;
  box-shadow: 0 0 0 6px rgba(214,59,59,.3); margin-top: 10px;
}
.rec-stop:active { transform: scale(.95); }

/* ---- 底部選單 ---- */
#sheet { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; }
.sheet-panel {
  width: 100%; max-height: 88vh; overflow-y: auto; background: var(--bg); border-radius: 16px 16px 0 0;
  padding: 18px 18px calc(18px + var(--safe-bottom)); animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet-panel h2 { font-size: 18px; margin: 0 0 10px; }
.sheet-panel p { margin: 6px 0; }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; padding: 12px; }
.menu-list { display: flex; flex-direction: column; }
.menu-list button { text-align: left; padding: 14px 6px; border-bottom: 1px solid var(--line); font-size: 16px; }
.menu-list button:last-child { border-bottom: 0; }
.menu-list button.danger { color: var(--danger); }
.opt { display: flex; align-items: flex-start; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.opt input { margin-top: 5px; width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.opt .d { display: block; font-size: 13px; color: var(--muted); }
.opt.off { opacity: .45; }
.field { margin: 12px 0; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.field input[type=text], .field input[type=password], .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 16px;
}
.field textarea { min-height: 70px; }
.cost { margin-top: 10px; font-size: 14px; }
.cat-pick { max-height: 55vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.cat-pick button { display: block; width: 100%; text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
.cat-pick button.sel { background: #e7f2ec; font-weight: 600; }

/* ---- 提示 ---- */
#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(96px + var(--safe-bottom)); z-index: 90;
  background: rgba(30,35,32,.94); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
