/* 宿寫 InnPen：共用品牌樣式（亮色／暗色兩套主題）
   主題由 <html data-theme="light|dark"> 控制：預設跟隨系統，作者按過切換鈕後以 localStorage('innpen-theme') 為準。
   元件裡只能用下面的語意化變數，不要寫死色碼，兩套主題才會一起正確。
   字型宣告在 /css/fonts.css（由 scripts/build-font.mjs 產生）。 */

:root {
  /* 兩套主題共用 */
  --primary: #f97316;
  --primary-hover: #ea5b18;
  /* 主要按鈕的底色：#F97316 配白字對比不足，按鈕改用 logo 原色 #EA5B18，20px 粗體白字達大字標準 */
  --primary-fill: #ea5b18;
  --primary-fill-hover: #d14e10;
  --secondary: #1780c3;
  --accent: #46bbbe;           /* 第二主色：進度、完成、AI 相關狀態 */
  --accent-soft: rgba(70, 187, 190, 0.15);
  --on-photo: rgba(0, 0, 0, 0.55); /* 疊在照片上的按鈕底 */

  --font-body: "Nunito", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-display: "Noto Serif TC", "PingFang TC", "Microsoft JhengHei", serif;
  --radius: 12px;
  --radius-pill: 9999px;
  /* lucide triangle-alert：警告用圖示表達，不另加顏色，才不會跟橘色連結或主要按鈕混淆 */
  --icon-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E");
}

/* 亮色（也是沒有設定 data-theme 時的預設） */
:root,
:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-soft: #faf7f3;
  --surface: #ffffff;
  --surface-2: #f3eee7;
  --border: #e8e0d6;
  --border-dashed: #d5ccc0;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --link: #c2410c;             /* 規範的 #EA5B18 在白底對比不足，同色系加深到 5.2 倍 */
  --error: #b42318;
  --glow: none;
  color-scheme: light;
}

/* 暗色：暖炭黑，對齊 lakeze.com 官網 */
:root[data-theme="dark"] {
  --bg: #141414;
  --bg-soft: #1a1a1a;
  --surface: #1f1f1f;
  --surface-2: #262626;
  --border: #2c2c2c;
  --border-dashed: #3a3a3a;
  --text: #f5f5f5;
  --text-muted: #b5b5b5;
  --link: #f97316;
  --error: #ff9f8a;
  --glow: radial-gradient(ellipse at 70% 20%, rgba(249, 115, 22, 0.1), transparent 55%);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: var(--glow);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  font-variant-numeric: tabular-nums; /* 數字等寬，額度與張數更新時不跳動 */
  transition: background-color 0.2s ease-out, color 0.2s ease-out;
}

::selection { background: var(--accent-soft); color: var(--text); }

a { color: var(--link); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 3px solid var(--secondary); outline-offset: 3px; }

[hidden] { display: none !important; }

/* 只給螢幕報讀器讀的文字 */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 40rem; margin: 0 auto; padding: 0 20px; }

/* 虛線分隔：InnPen 的簽名元素（母品牌人客多用實線）。用背景畫，才能固定 6px 線段、6px 間距 */
.dash-bottom, .dash-top, .dash-y { background-repeat: no-repeat; }
.dash-bottom { background-image: repeating-linear-gradient(90deg, var(--border-dashed) 0 6px, transparent 6px 12px); background-size: 100% 1px; background-position: bottom; }
.dash-top { background-image: repeating-linear-gradient(90deg, var(--border-dashed) 0 6px, transparent 6px 12px); background-size: 100% 1px; background-position: top; }
.dash-y {
  background-image:
    repeating-linear-gradient(90deg, var(--border-dashed) 0 6px, transparent 6px 12px),
    repeating-linear-gradient(90deg, var(--border-dashed) 0 6px, transparent 6px 12px);
  background-size: 100% 1px, 100% 1px;
  background-position: top, bottom;
}

/* 頁首：logo 與主題切換鈕 */
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0; }
.masthead .brand { display: inline-flex; align-items: center; }
.masthead .brand img { display: block; height: 32px; width: auto; }
.masthead .tools { display: flex; align-items: center; gap: 12px; min-width: 0; }
.masthead .who { color: var(--text-muted); font-size: 14px; overflow-wrap: anywhere; text-align: right; }
/* logo 依主題與螢幕寬度切換：亮色用彩色字標、暗色用反白字標，手機窄螢幕只放圖標 */
.logo-dark, .logo-mark { display: none !important; }
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }
@media (max-width: 639px) {
  .logo-light, .logo-dark, :root[data-theme="dark"] .logo-dark { display: none !important; }
  .masthead .brand .logo-mark { display: block !important; height: 28px; }
}

.theme-toggle {
  width: 36px; height: 36px; flex: none; display: inline-grid; place-items: center; padding: 0;
  border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; transition: background-color 0.2s ease-out, color 0.2s ease-out, border-color 0.2s ease-out;
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* 標題：頁面主標用明體 900，其他標題用黑體 */
h1 {
  font-family: var(--font-display); font-weight: 900; line-height: 1.2; letter-spacing: 0.02em;
  font-size: clamp(1.9rem, 7vw, 2.6rem); margin: 28px 0 8px; text-wrap: balance;
}
h2 { font-size: 1.15rem; font-weight: 700; line-height: 1.4; margin: 36px 0 8px; text-wrap: balance; }

.lead { margin: 0 0 20px; color: var(--text-muted); }
.fine { color: var(--text-muted); font-size: 14px; }

/* 按鈕：一律膠囊形。主要（橘）一個畫面只放一顆 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 20px; border-radius: var(--radius-pill);
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  transition: background-color 0.2s ease-out, border-color 0.2s ease-out, color 0.2s ease-out, transform 0.1s ease-out;
}
.btn:hover { border-color: var(--border-dashed); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
/* 20px 粗體屬於大字，白字在 #EA5B18 上達到大字的對比標準 */
.btn-primary {
  width: 100%; min-height: 56px; font-size: 20px;
  background: var(--primary-fill); border-color: var(--primary-fill); color: #fff;
}
.btn-primary:hover { background: var(--primary-fill-hover); border-color: var(--primary-fill-hover); }
/* 暫時不能用的主要按鈕：拿掉橘色，不讓橘色出現在做不到的動作上；仍可點開說明 */
.btn-primary[aria-disabled="true"],
.btn-primary[aria-disabled="true"]:hover {
  background: var(--surface-2); border-color: var(--border); color: var(--text-muted);
}
.btn-small { min-height: 40px; padding: 6px 16px; font-size: 15px; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-danger { color: var(--error); }

.icon-btn {
  width: 40px; height: 40px; flex: none; display: inline-grid; place-items: center; padding: 0;
  border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); cursor: pointer;
  transition: background-color 0.2s ease-out, color 0.2s ease-out;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* 提示框 */
.notice {
  margin: 16px 0 0; padding: 12px 14px; border-radius: var(--radius);
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-muted); font-size: 15px;
}
.notice strong { color: var(--text); }
/* 擋下時的提醒：虛線框（InnPen 簽名）加警告圖示，不另加顏色 */
.notice.is-warn { border: 1px dashed var(--text-muted); color: var(--text); padding-left: 42px; position: relative; }
.notice.is-warn::before {
  content: ""; position: absolute; left: 14px; top: 15px; width: 18px; height: 18px;
  background: currentColor; -webkit-mask: var(--icon-alert) center / contain no-repeat; mask: var(--icon-alert) center / contain no-repeat;
}
.notice.is-error { border-color: var(--error); color: var(--text); }
/* 狀態提示（AI 分析、草稿已儲存、照片準備好了）：藍綠邊線與淡藍綠底 */
.notice.is-status { background: var(--accent-soft); border: 0; border-left: 3px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0; color: var(--text); }

.error-text { color: var(--error); }

/* 說明視窗：被擋下時說清楚原因與下一步 */
dialog {
  width: min(28rem, calc(100vw - 32px)); padding: 24px 22px 20px;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); color: var(--text);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog h2 { margin: 0 0 8px; font-size: 1.3rem; }
dialog p { margin: 0 0 12px; color: var(--text-muted); }
dialog .actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 18px; }
dialog .actions .btn { min-width: 6rem; }

/* ---------- 登入後的頁首：頭像與選單（由 /js/account.js 產生） ---------- */
.account { position: relative; display: flex; align-items: center; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 15px; line-height: 1;
  border: 1px solid var(--border); overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.lg { width: 48px; height: 48px; font-size: 20px; }
.avatar.xl { width: 80px; height: 80px; font-size: 30px; }
.who-btn {
  display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; color: var(--text);
  font: inherit; font-weight: 700; font-size: 15px; padding: 2px; border-radius: var(--radius-pill); cursor: pointer;
}
.who-btn .nm { max-width: 10em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-btn .chev { width: 16px; height: 16px; color: var(--text-muted); transition: transform 0.2s ease-out; }
.who-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
@media (max-width: 639px) { .who-btn .nm { display: none; } }
.menu {
  position: absolute; z-index: 30; right: 0; top: calc(100% + 10px); width: 288px; padding: 8px 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
}
.menu .me { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; padding: 10px 16px 14px; }
.menu .me b { display: block; line-height: 1.3; overflow-wrap: anywhere; }
.menu .me small { display: block; color: var(--text-muted); font-size: 13px; overflow-wrap: anywhere; }
.menu a { display: flex; align-items: center; gap: 12px; padding: 10px 16px; color: var(--text); font-weight: 700; font-size: 15px; }
.menu a:hover, .menu a:focus-visible { background: var(--bg-soft); text-decoration: none; outline-offset: -3px; }
.menu a svg { width: 18px; height: 18px; flex: none; color: var(--text-muted); }
.menu a .tag { margin-left: auto; }
.menu .sep { height: 1px; margin: 6px 16px; }
@media (max-width: 639px) { .menu { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; } }

/* 小標籤（狀態，不是按鈕） */
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--text-muted); white-space: nowrap; }
.tag.ok { background: var(--accent-soft); color: var(--text); }
.tag.ok::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

/* ---------- 後台雙欄：電腦左側選單、手機只有內容（換頁用頭像選單） ---------- */
body.is-studio .wrap { max-width: 76rem; }
.studio { display: block; }
.studio-side { display: none; }
@media (min-width: 900px) {
  .studio { display: grid; grid-template-columns: 232px 1fr; gap: 40px; align-items: start; }
  .studio-side {
    display: block; position: sticky; top: 0; padding: 20px 16px 20px 0;
    background-image: repeating-linear-gradient(180deg, var(--border-dashed) 0 6px, transparent 6px 12px);
    background-size: 1px 100%; background-repeat: no-repeat; background-position: right; min-height: calc(100vh - 69px);
  }
}
.studio-main { min-width: 0; }
.side-site { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; padding: 0 6px 14px; }
.side-site b { display: block; line-height: 1.3; font-size: 15px; overflow-wrap: anywhere; }
.side-site small { color: var(--text-muted); font-size: 13px; }
.side-nav a, .side-nav .later { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--text); font-weight: 700; font-size: 15px; }
.side-nav a:hover { background: var(--surface-2); text-decoration: none; }
.side-nav a[aria-current="page"] { background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.side-nav svg { width: 18px; height: 18px; flex: none; color: var(--text-muted); }
.side-nav a[aria-current="page"] svg { color: var(--text); }
.side-nav .later { color: var(--text-muted); font-weight: 400; }
.side-nav .soon { margin-left: auto; font-size: 12px; color: var(--text-muted); font-weight: 400; }
.side-nav .group { margin: 18px 12px 6px; font-size: 13px; color: var(--text-muted); }

/* 分頁 */
.tabs { display: flex; gap: 4px; margin: 20px 0 0; }
.tabs button { font: inherit; font-weight: 700; color: var(--text-muted); padding: 10px 16px 12px; border: 0; border-bottom: 3px solid transparent; background: none; cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }
.tabs button span { font-weight: 400; margin-left: 4px; }

/* 開關（啟用／停用） */
.switch { width: 44px; height: 26px; border-radius: var(--radius-pill); background: var(--surface-2); border: 1px solid var(--border); position: relative; flex: none; padding: 0; cursor: pointer; transition: background-color 0.2s ease-out; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: left 0.2s ease-out; }
.switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"]::after { left: 20px; }
.switch:disabled { opacity: 0.5; cursor: not-allowed; }

/* 表單欄位（膠囊形） */
.input, .select {
  width: 100%; min-height: 52px; font: inherit; padding: 10px 18px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.input::placeholder { color: var(--text-muted); }
.input[readonly] { background: var(--bg-soft); color: var(--text-muted); }
.input:focus-visible, .select:focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
