/* =========================================================
   日記寫作引導・樣式
   ========================================================= */
:root {
  --ink: #33302c;
  --ink-soft: #6b635a;
  --line: #e6ded2;
  --paper: #fffdf8;
  --cream: #f7f1e8;
  --accent: #c2703d;
  --accent-soft: #f6e6d8;
  --green: #4a7c59;
  --green-soft: #e4efe6;
  --shadow: 0 2px 10px rgba(80, 60, 40, .08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Noto Sans TC", "PingFang HK", "PingFang SC", "Microsoft JhengHei", "Heiti TC", sans-serif;
  color: var(--ink);
  background: var(--cream);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

button { font-family: inherit; }

/* ---------------- 登入頁 ---------------- */
.login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 20px;
  background:
    radial-gradient(900px 500px at 15% -10%, #fff8ec 0%, transparent 60%),
    radial-gradient(700px 400px at 100% 0%, #eef3ec 0%, transparent 55%),
    var(--cream);
}
.login-card {
  width: 100%; max-width: 560px;
  background: var(--paper);
  border-radius: 20px;
  padding: 38px 34px 30px;
  box-shadow: 0 18px 50px rgba(90, 70, 45, .14);
  border: 1px solid var(--line);
}
.login-badge {
  display: inline-block; font-size: 13px; letter-spacing: .08em;
  color: var(--accent); background: var(--accent-soft);
  padding: 5px 12px; border-radius: 999px; margin-bottom: 16px;
}
.login-card h1 {
  margin: 0 0 14px; font-size: 32px; line-height: 1.35; font-weight: 800;
  letter-spacing: .01em;
}
.login-card h1 span { color: var(--accent); }
.prompt {
  background: #fbf6ee; border-left: 4px solid var(--accent);
  padding: 14px 16px; border-radius: 0 10px 10px 0;
  font-size: 15px; color: var(--ink-soft); margin: 0 0 24px;
}
#loginForm label { display: block; font-size: 14px; font-weight: 700; margin: 14px 0 6px; }
.req { color: var(--accent); font-weight: 600; font-size: 13px; }
.opt { color: var(--ink-soft); font-weight: 400; font-size: 13px; }
#loginForm input {
  width: 100%; padding: 12px 14px; font-size: 16px;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink);
}
#loginForm input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-tip { font-size: 13px; color: var(--green); background: var(--green-soft); padding: 10px 12px; border-radius: 8px; margin: 14px 0 0; }
.login-btns { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.login-foot { font-size: 12.5px; color: var(--ink-soft); margin: 18px 0 0; text-align: center; }

/* ---------------- 按鈕 ---------------- */
.btn {
  border: 1px solid transparent; border-radius: 10px;
  padding: 11px 18px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #ad6033; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #faf5ee; border-color: #d9cdbd; }
.btn-sm { padding: 7px 12px; font-size: 13.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------------- 頂欄 ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 22px;
  background: var(--paper); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  background: var(--accent); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.topbar-title { font-weight: 800; font-size: 16px; }
.topbar-sub { font-size: 12.5px; color: var(--ink-soft); }
.dot { opacity: .5; }
.topbar-right { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- 步驟導覽 ---------------- */
.steps {
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 22px;
  background: #fbf7f0; border-bottom: 1px solid var(--line);
  position: sticky; top: 62px; z-index: 15;
}
.chip {
  flex: none; border: 1px solid var(--line); background: #fff;
  color: var(--ink-soft); border-radius: 999px; padding: 6px 14px;
  font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.chip.done { color: var(--ink); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }

/* ---------------- 主版面 ---------------- */
.stage {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px; padding: 20px 22px 60px; align-items: start;
  max-width: 1500px; margin: 0 auto;
}

/* ---------------- 題目欄 ---------------- */
.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-head h2 { margin: 0 0 4px; font-size: 17px; font-weight: 800; }
.q { padding: 16px 0; border-top: 1px dashed var(--line); }
.q:first-of-type { border-top: none; padding-top: 4px; }
.q-title { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.q-hint { font-size: 13.5px; color: var(--ink-soft); margin-bottom: 12px; }
.opts { display: grid; gap: 9px; }
.opt {
  display: flex; gap: 10px; align-items: flex-start; text-align: left;
  border: 1.5px solid var(--line); background: #fff; border-radius: 12px;
  padding: 12px 14px; cursor: pointer; transition: .12s; width: 100%;
}
.opt:hover { border-color: #d5c8b6; background: #fffdf9; }
.opt.on { border-color: var(--accent); background: var(--accent-soft); }
.opt-mark { font-size: 16px; line-height: 1.6; color: var(--ink-soft); }
.opt.on .opt-mark { color: var(--accent); }
.opt-main { display: flex; flex-direction: column; }
.opt-label { font-size: 15px; font-weight: 600; }
.opt-desc { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.fb { font-size: 13.5px; margin-top: 10px; padding: 10px 12px; border-radius: 8px; }
.fb.ok { background: var(--green-soft); color: #2f5c3c; }
.fb.warn { background: #fdeee7; color: #93452a; }
.fb.empty { display: none; }

.nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 4px; }

/* ---------------- 檢查清單 ---------------- */
.check { list-style: none; margin: 0; padding: 0; }
.check li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 14.5px; }
.check li:last-child { border-bottom: none; }
.check li.manual { cursor: pointer; }
.check li.manual:hover { background: #fdfaf4; }
.check .box { flex: none; width: 24px; text-align: center; }
.check .ct { display: flex; flex-direction: column; }
.check em { font-style: normal; font-size: 12.5px; color: var(--ink-soft); }
.check li.ok b { color: #2f5c3c; }

.actions { display: flex; flex-wrap: wrap; gap: 9px; }
.tip { font-size: 13px; color: var(--ink-soft); margin: 12px 0 0; }
.wordrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; padding: 6px 0; }
.wt { font-size: 13px; font-weight: 700; color: var(--accent); flex: none; }
.wi { display: flex; gap: 6px; flex-wrap: wrap; }
.wi code {
  background: #fbf6ee; border: 1px solid var(--line); border-radius: 6px;
  padding: 2px 8px; font-size: 13px; font-family: inherit;
}
.quote { font-size: 13.5px; color: var(--ink-soft); background: #fbf6ee; padding: 10px 12px; border-radius: 8px; margin: 10px 0; }

/* ---------------- 預覽／日記簿 ---------------- */
.preview { position: sticky; top: 118px; }
.preview-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; font-weight: 700; margin-bottom: 8px; color: var(--ink-soft);
}
.count-badge {
  font-size: 12.5px; font-weight: 700; background: var(--green-soft);
  color: #2f5c3c; padding: 3px 10px; border-radius: 999px;
}
.sheet {
  background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 26px 30px; min-height: 420px;
  box-shadow: var(--shadow);
  background-image: repeating-linear-gradient(transparent, transparent 31px, #eef0f4 31px, #eef0f4 32px);
  background-position: 0 8px;
}
.sheet-head {
  font-weight: 800; font-size: 15px; letter-spacing: .04em;
  color: var(--accent); border-bottom: 2px solid var(--accent-soft);
  padding-bottom: 8px; margin-bottom: 14px;
}
.sheet-body p {
  margin: 0 0 12px; text-indent: 2em; font-size: 16px; line-height: 32px;
  font-family: "Kaiti SC", "STKaiti", "Kaiti TC", "Noto Serif TC", serif;
  text-align: justify;
}
.editor {
  width: 100%; min-height: 460px; border: 1.5px dashed var(--line);
  border-radius: 10px; padding: 12px 14px; resize: vertical;
  font-family: "Kaiti SC", "STKaiti", "Noto Serif TC", serif;
  font-size: 16px; line-height: 32px; color: var(--ink); background: #fffefb;
}
.editor:focus { outline: none; border-color: var(--accent); }
.preview-foot { font-size: 12.5px; color: var(--ink-soft); margin-top: 10px; }

/* ---------------- 錦囊抽屜 ---------------- */
.drawer {
  position: fixed; inset: 0; background: rgba(50, 40, 30, .35);
  z-index: 50; display: flex; justify-content: flex-end;
}
.drawer-panel {
  width: min(560px, 100%); height: 100%; background: var(--paper);
  overflow-y: auto; padding: 20px 24px 60px; box-shadow: -8px 0 30px rgba(0,0,0,.15);
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--paper); padding-bottom: 10px; }
.drawer-head h2 { margin: 0; font-size: 19px; }
.drawer-body h3 { font-size: 15px; margin: 20px 0 6px; color: var(--accent); }
.drawer-body .skill { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.drawer-body .skill b { display: block; font-size: 14px; }
.drawer-body .skill span { font-size: 13.5px; color: var(--ink-soft); }
.traps { padding-left: 20px; margin: 6px 0; }
.traps li { font-size: 13.5px; margin-bottom: 5px; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: #33302c; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 80; box-shadow: 0 6px 20px rgba(0,0,0,.2);
}

/* ---------------- 列印 ---------------- */
#printHead { display: none; }
@media print {
  body { background: #fff; }
  .topbar, .steps, .qcol, .preview-head, .preview-foot, .drawer, .toast, .login { display: none !important; }
  .stage { display: block; padding: 0; }
  .preview { position: static; }
  .sheet { border: none; box-shadow: none; background-image: none; padding: 0; min-height: auto; }
  .sheet-head { border-bottom: 1px solid #999; color: #000; }
  .editor { border: none; min-height: auto; overflow: visible; resize: none; }
  #printHead { display: block; font-size: 13px; color: #000; margin-bottom: 10px; }
  @page { margin: 18mm; }
}

/* ---------------- 手機 ---------------- */
@media (max-width: 900px) {
  .stage { grid-template-columns: 1fr; }
  .preview { position: static; }
  .topbar-title { font-size: 15px; }
  .steps { top: 58px; }
  .login-card { padding: 28px 22px; }
  .login-card h1 { font-size: 26px; }
}
