/* Shared cascade order. Important utility exceptions stay local and documented. */
@layer base, components, themes, overrides;
@layer components {
/* ============================================================
   PDF 作業講解器 — 暖紙與炭墨學習工作桌
   ============================================================
   結構與行為不變，只做視覺收斂：
   - 暖白、炭黑與少量陶土色
   - 平接版面、1px 分隔線、小圓角、幾無陰影
   - 介面統一用繁體中文無襯線字體；AI 回答保留原本排版
   ============================================================ */

/* 手機拍照傳到電腦 */
.phone-upload-dialog { width: min(520px, calc(100vw - 32px)); max-width: 520px; max-height: 85dvh; overflow: auto; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.phone-upload-dialog::backdrop { background: var(--backdrop); }
.phone-upload-qr { display: grid; place-items: center; margin: 20px auto; }
.phone-upload-qr:empty { display: none; }
.phone-upload-qr canvas { padding: 16px; background: #fff; box-sizing: content-box; max-width: 100%; }
.phone-upload-link-label { display: grid; gap: 6px; margin: 18px 0; }
.phone-upload-link-label input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); background: var(--panel-2); font-size: 13px; }
.phone-upload-actions, .camera-actions { display: flex; flex-wrap: wrap; gap: 8px; }
body.phone-camera-page { height: auto; min-height: 100dvh; overflow: auto; }
.phone-camera-root { height: auto; min-height: 100%; overflow: auto; }
.phone-camera-main { width: min(100%, 560px); margin: auto; padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom)); }
.phone-camera-main h1 { font-size: clamp(26px, 7vw, 36px); line-height: 1.35; margin: 24px 0 16px; }
.camera-status { padding: 14px; border: 1px solid var(--border); background: var(--panel); border-radius: var(--radius); }
.camera-actions .btn { flex: 1; min-height: 48px; }
.camera-photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 0; list-style: none; }
.camera-photos li { display: grid; gap: 6px; padding: 8px; border: 1px solid var(--border); background: var(--panel); border-radius: var(--radius); }
.camera-photos img { width: 100%; height: 170px; object-fit: contain; background: var(--panel-2); }
.camera-photos span { padding: 0 4px; font-size: 13px; }
.camera-send { width: 100%; min-height: 48px; margin-top: 12px; }

/* ---------- 3. Reset 與基底 ---------- */
.study-action-dialog { width: min(560px, calc(100vw - 24px)); max-height: 88dvh; overflow: auto; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.study-action-dialog::backdrop { background: var(--backdrop); }
.study-action-dialog h2 { margin: 0 0 18px; font-size: 20px; }
.study-action-dialog form { display: grid; gap: 16px; }
.study-action-field { display: grid; gap: 7px; min-width: 0; }
.study-action-field[hidden] { display: none; }
.study-action-field > span { font-weight: 600; font-size: 14px; }
.study-action-field select, .study-action-field textarea { width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--panel-2); color: var(--text); font-size: 16px; }
.study-action-field textarea { resize: vertical; }
.study-action-preview { max-height: 32dvh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; background: var(--panel-2); }
.study-action-preview:empty { display: none; }
.study-action-preview pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 14px; }
.study-action-preview img { display: block; max-width: 100%; height: auto; margin-top: 10px; }
.study-action-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.study-action-buttons .btn { min-height: 44px; }
.study-action-error { margin: 0; color: var(--danger, #b83232); }
.study-action-error:empty { display: none; }
.study-action-dialog .muted { margin: 0; }
@media (max-width: 600px) { .study-action-dialog { padding: 18px; } .study-action-buttons .btn { flex: 1; } }

/* Visibility is an explicit utility exception. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* 原生表單元件也跟隨介面字體，避免按鈕與選單使用瀏覽器預設字體。 */
button,
input,
select,
textarea {
  font-family: inherit;
}

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

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

h1,
h2,
h3 {
  font-family: var(--font-ui);
  font-weight: 600;
  color: var(--text);
}

h1 {
  font-size: 20px;
  line-height: 1.4;
}

h2 {
  font-size: 18px;
  line-height: 1.4;
  font-weight: 600;
}

h3 {
  font-size: 15px;
  line-height: 1.5;
}

.muted,
.small,
.status,
.check,
.field,
.msg-note,
.msg-model-switch {
  line-height: 1.6;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

}

@layer overrides { [hidden] { display: none !important; } }
