:root {
  --ink: #191a18;
  --muted: #6e716c;
  --line: #dcdcd4;
  --paper: #f5f3ee;
  --card: #fffefa;
  --accent: #ef4f2f;
  --accent-dark: #cc381d;
  --accent-soft: #fff0eb;
  --lime: #dfe85e;
  --green: #316b54;
  --shadow: 0 24px 70px rgba(36, 35, 29, .09);
  --radius: 22px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 9%, rgba(223, 232, 94, .16), transparent 20rem),
    linear-gradient(180deg, #f8f6f1 0, var(--paper) 42rem);
  font-family: "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }

button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(239, 79, 47, .25);
  outline-offset: 3px;
}

.app-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }

.topbar {
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(25, 26, 24, .09);
}

.brand {
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--ink);
  border-radius: 50%;
  font: 800 19px/1 Georgia, serif;
}

.brand strong { display: block; font-size: 16px; letter-spacing: .03em; }
.brand small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.topbar-actions { display: flex; gap: 8px; }
.cloud-button {
  display: inline-flex;
  height: 40px;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.65);
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}
.cloud-dot { width: 7px; height: 7px; background: #aaa; border-radius: 50%; }
.cloud-button.connected .cloud-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(49,107,84,.12); }
.top-nav-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.65);
  padding: 0 14px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.top-nav-button.accent { color: var(--accent); border-color: rgba(239,79,47,.3); }

.icon-button, .dialog-close {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, .65);
  cursor: pointer;
  transition: .2s ease;
}

.icon-button:hover, .dialog-close:hover { background: #fff; border-color: #b8b9b2; transform: translateY(-1px); }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.cloud-dialog {
  width: min(560px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  box-shadow: 0 28px 90px rgba(25,26,24,.24);
}
.cloud-dialog::backdrop { background: rgba(25,26,24,.46); backdrop-filter: blur(4px); }
.cloud-dialog-shell { padding: 26px; }
.cloud-intro, .cloud-note { color: var(--muted); font-size: 11px; line-height: 1.65; }
.cloud-key-field { display: block; margin: 20px 0 12px; }
.cloud-key-field span { display: block; margin-bottom: 7px; font-size: 10px; font-weight: 800; }
.cloud-key-field input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f7f5f0;
}
.cloud-status { padding: 11px 12px; color: #54564f; background: #efede7; border-radius: 9px; font-size: 10px; }
.cloud-status.error { color: #8e2e1d; background: #fff0eb; }
.cloud-status.success { color: var(--green); background: #edf5f0; }
.cloud-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.secondary-button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}
.primary-button.compact { min-height: 38px; padding: 0 15px; }

.hero {
  min-height: 330px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  padding: 55px 5%;
}

.eyebrow {
  display: block;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .2em;
  margin-bottom: 17px;
}

.hero h1 {
  margin: 0;
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: clamp(42px, 6vw, 72px);
  line-height: 1.08;
  font-weight: 500;
  letter-spacing: -.04em;
}

.hero h1 em { color: var(--accent); font-weight: 500; }
.hero p { color: var(--muted); font-size: 16px; margin: 23px 0 0; }

.time-chip {
  position: relative;
  flex: 0 0 auto;
  width: 170px;
  height: 170px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px solid rgba(25, 26, 24, .15);
  border-radius: 50%;
  transform: rotate(4deg);
}

.time-chip::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px dashed rgba(25, 26, 24, .18);
  border-radius: 50%;
}

.time-chip span:last-child { max-width: 90px; font-size: 12px; font-weight: 700; line-height: 1.4; }
.time-chip strong { color: var(--accent); display: block; font: 600 45px/1 Georgia, serif; }
.time-icon { position: absolute; top: 16px; right: 29px; color: var(--accent); font-size: 22px; }

.capture-card {
  padding: clamp(24px, 5vw, 58px);
  background: var(--card);
  border: 1px solid rgba(25, 26, 24, .09);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.capture-heading, .library-heading, .dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.capture-heading > div:first-child { display: grid; grid-template-columns: 32px auto; column-gap: 14px; }
.capture-heading h2, .library-heading h2, .dialog-header h2 { margin: 0; font: 600 27px/1.2 Georgia, "Noto Serif TC", serif; }
.capture-heading p { grid-column: 2; margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.step-number {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  padding-top: 8px;
}

.mode-switch { display: flex; padding: 4px; background: #efeee9; border-radius: 999px; }
.mode-button {
  border: 0;
  border-radius: 999px;
  background: transparent;
  padding: 9px 16px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.mode-button.active { color: #fff; background: var(--ink); box-shadow: 0 4px 10px rgba(25, 26, 24, .16); }

.drop-grid { display: grid; gap: 16px; margin-top: 25px; }
.drop-grid.compare-mode { grid-template-columns: 1fr 1fr; }

.drop-zone {
  position: relative;
  min-height: 258px;
  overflow: hidden;
  border: 1.5px dashed #b9bbb3;
  border-radius: 17px;
  background:
    linear-gradient(90deg, rgba(25,26,24,.025) 1px, transparent 1px),
    linear-gradient(rgba(25,26,24,.025) 1px, transparent 1px),
    #fbfaf6;
  background-size: 24px 24px;
  cursor: pointer;
  transition: .2s ease;
}
.drop-zone:hover, .drop-zone.dragging, .drop-zone.paste-target {
  border-color: var(--accent);
  background-color: var(--accent-soft);
}
.drop-zone.paste-target { box-shadow: 0 0 0 4px rgba(239,79,47,.08); }

.drop-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 20px;
}
.drop-empty strong { font-size: 15px; }
.drop-empty > span:not(.paste-icon):not(.compare-label) { color: var(--muted); font-size: 12px; }

.paste-icon {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: #fff;
  border: 1px solid #e5e2da;
  border-radius: 50%;
  margin-bottom: 6px;
  box-shadow: 0 8px 20px rgba(25,26,24,.07);
}
.paste-icon svg { width: 23px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.text-button { color: var(--accent); background: none; border: 0; font-weight: 800; font-size: 12px; cursor: pointer; padding: 5px 9px; }
.text-button:hover { text-decoration: underline; }
.compare-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .18em;
  border: 1px solid #d6d6cf;
  border-radius: 999px;
  padding: 5px 9px;
  margin-bottom: 5px;
}
.compare-label.after { color: var(--green); border-color: rgba(49,107,84,.28); background: rgba(49,107,84,.06); }

.drop-preview { position: absolute; inset: 0; background: #ebeae4; }
.drop-preview img { width: 100%; height: 100%; object-fit: contain; display: block; }
.preview-actions {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.slot-label { color: #fff; background: rgba(25,26,24,.78); border-radius: 999px; padding: 5px 9px; font-size: 10px; font-weight: 800; }
.remove-image {
  width: 30px;
  height: 30px;
  pointer-events: auto;
  color: #fff;
  background: rgba(25,26,24,.78);
  border: 0;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.paste-hint { margin: 12px 0 0; color: var(--muted); text-align: center; font-size: 11px; }
kbd { font-family: inherit; }
.paste-hint kbd { color: var(--ink); background: #edebe5; border: 1px solid #dcd9d0; border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; }

.form-section { padding-top: 38px; }
.section-label { display: grid; grid-template-columns: 32px auto; column-gap: 14px; margin-bottom: 14px; }
.section-label strong { display: block; font: 600 20px/1.25 Georgia, "Noto Serif TC", serif; }
.section-label small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 4px; }

textarea, .advanced-fields input, .advanced-fields select, .search-wrap input {
  width: 100%;
  color: var(--ink);
  background: #f9f8f4;
  border: 1px solid var(--line);
  border-radius: 12px;
}
textarea {
  min-height: 104px;
  resize: vertical;
  padding: 16px 17px;
  line-height: 1.65;
}
textarea::placeholder, input::placeholder { color: #9a9c96; }
textarea:focus, .advanced-fields input:focus, .advanced-fields select:focus, .search-wrap input:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239,79,47,.08);
}
.note-meta { display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 10px; margin-top: 7px; }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; padding-left: 46px; }
.tag-button {
  border: 1px solid #d7d7cf;
  border-radius: 999px;
  background: #fff;
  padding: 9px 13px;
  font-size: 12px;
  cursor: pointer;
  transition: .15s ease;
}
.tag-button:hover { border-color: #9b9d96; transform: translateY(-1px); }
.tag-button.selected { color: #fff; background: var(--accent); border-color: var(--accent); box-shadow: 0 5px 12px rgba(239,79,47,.18); }
.tag-button.selected::before { content: "✓"; margin-right: 5px; font-weight: 800; }

.advanced-panel { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-top: 35px; }
.advanced-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 2px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}
.advanced-panel summary::-webkit-details-marker { display: none; }
.advanced-panel summary svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; transition: transform .2s; }
.advanced-panel[open] summary svg { transform: rotate(180deg); }
.advanced-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; padding: 2px 0 19px; }
.advanced-fields label span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; margin-bottom: 7px; }
.advanced-fields input, .advanced-fields select { height: 44px; padding: 0 12px; }

.capture-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 25px; }
.save-status { color: var(--muted); display: flex; align-items: center; gap: 8px; font-size: 11px; }
.status-dot { width: 7px; height: 7px; background: var(--green); border-radius: 50%; box-shadow: 0 0 0 4px rgba(49,107,84,.1); }
.primary-button, .secondary-button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  transition: .2s ease;
}
.primary-button {
  min-width: 212px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: #fff;
  background: var(--accent);
  padding: 15px 17px 15px 22px;
  box-shadow: 0 12px 25px rgba(239,79,47,.23);
}
.primary-button:hover { background: var(--accent-dark); transform: translateY(-2px); box-shadow: 0 15px 28px rgba(239,79,47,.28); }
.primary-button:disabled { opacity: .55; cursor: wait; transform: none; }
.primary-button kbd { color: rgba(255,255,255,.8); font-size: 10px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.18); border-radius: 5px; padding: 3px 6px; }

.library-section { padding: 115px 0 100px; }
.library-heading { align-items: flex-end; margin-bottom: 30px; }
.library-heading .eyebrow { margin-bottom: 9px; }
.library-heading h2 { font-size: 35px; }
.search-wrap { position: relative; width: min(340px, 100%); }
.search-wrap svg { position: absolute; left: 14px; top: 50%; width: 17px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.search-wrap input { height: 44px; padding: 0 15px 0 40px; }

.status-tabs {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.status-tabs::-webkit-scrollbar { display: none; }
.status-tab {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 13px 16px 15px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.status-tab::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px; background: transparent; }
.status-tab b { min-width: 20px; padding: 2px 6px; color: var(--muted); background: #e8e6df; border-radius: 999px; font-size: 10px; }
.status-tab.active { color: var(--ink); }
.status-tab.active::after { background: var(--accent); }
.status-tab.active b { color: #fff; background: var(--accent); }

.record-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 19px; }
.record-card {
  position: relative;
  overflow: visible;
  background: var(--card);
  border: 1px solid rgba(25,26,24,.1);
  border-radius: 17px;
  box-shadow: 0 9px 30px rgba(36,35,29,.04);
  transition: .2s ease;
}
.record-card:hover { transform: translateY(-3px); box-shadow: 0 18px 40px rgba(36,35,29,.08); }
.record-open { width: 100%; padding: 0; text-align: left; background: none; border: 0; cursor: pointer; }
.record-media {
  height: 190px;
  display: grid;
  grid-template-columns: repeat(var(--image-count, 1), 1fr);
  overflow: hidden;
  background: #e9e7e1;
  border-radius: 16px 16px 0 0;
}
.record-media img { width: 100%; height: 100%; display: block; object-fit: cover; }
.record-media img + img { border-left: 2px solid var(--card); }
.text-record {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 25px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(223,232,94,.27), rgba(255,255,255,.15)),
    #eeede7;
  font: italic 19px/1.55 Georgia, "Noto Serif TC", serif;
  text-align: center;
}
.text-record::before { content: "“"; position: absolute; color: var(--accent); font-size: 70px; opacity: .23; transform: translateY(-40px); }
.record-body { padding: 18px 18px 13px; }
.record-kicker { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.record-state { color: var(--accent); font-size: 9px; font-weight: 900; letter-spacing: .1em; }
.record-kicker time { color: var(--muted); font-size: 9px; }
.record-body h3 { overflow: hidden; margin: 0 0 7px; font: 600 18px/1.35 Georgia, "Noto Serif TC", serif; white-space: nowrap; text-overflow: ellipsis; }
.record-note { height: 40px; overflow: hidden; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.65; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.record-tags { min-height: 26px; display: flex; flex-wrap: wrap; gap: 5px; margin-top: 13px; }
.mini-tag { color: #60635e; background: #efeee9; border-radius: 999px; padding: 4px 7px; font-size: 9px; }
.record-actions { position: relative; display: flex; gap: 7px; padding: 0 13px 13px; }
.ai-button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--ink);
  background: var(--lime);
  border: 0;
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
}
.ai-button:hover { filter: brightness(.96); }
.ai-button svg { width: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.more-button { width: 37px; border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; font-weight: 800; letter-spacing: .06em; }
.card-menu {
  position: absolute;
  right: 13px;
  bottom: 55px;
  z-index: 5;
  width: 155px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 15px 35px rgba(25,26,24,.14);
}
.card-menu button { width: 100%; text-align: left; border: 0; border-radius: 6px; background: none; padding: 8px 9px; font-size: 11px; cursor: pointer; }
.card-menu button:hover { background: #f2f1ec; }
.card-menu .danger { color: #b22919; }

.empty-state { display: none; text-align: center; padding: 70px 20px; border: 1px dashed #c8c8c0; border-radius: 17px; }
.empty-state.visible { display: block; }
.empty-mark { width: 56px; height: 56px; display: grid; place-items: center; margin: 0 auto 16px; color: #fff; background: var(--ink); border-radius: 50%; font: 700 23px Georgia, serif; }
.empty-state h3 { margin: 0 0 8px; font: 600 21px Georgia, "Noto Serif TC", serif; }
.empty-state p { margin: 0 0 21px; color: var(--muted); font-size: 12px; }
.secondary-button { padding: 11px 17px; background: #fff; border: 1px solid var(--line); }
.secondary-button:hover { border-color: var(--ink); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  background: var(--ink);
  border-radius: 999px;
  padding: 12px 18px 12px 12px;
  box-shadow: 0 15px 40px rgba(25,26,24,.25);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 20px);
  transition: .25s ease;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast-icon { width: 25px; height: 25px; display: grid; place-items: center; color: var(--ink); background: var(--lime); border-radius: 50%; font-weight: 900; }
.toast span:last-child { font-size: 12px; font-weight: 800; }

.detail-dialog {
  width: min(880px, calc(100% - 30px));
  max-height: calc(100vh - 30px);
  padding: 0;
  color: var(--ink);
  background: var(--card);
  border: 0;
  border-radius: 20px;
  box-shadow: 0 35px 100px rgba(25,26,24,.24);
}
.detail-dialog::backdrop { background: rgba(25,26,24,.52); backdrop-filter: blur(5px); }
.dialog-shell { padding: clamp(22px, 4vw, 40px); }
.dialog-header { padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.dialog-header .eyebrow { margin-bottom: 7px; }
.dialog-close { flex: 0 0 auto; font-size: 23px; line-height: 1; }
.dialog-images { display: grid; grid-template-columns: repeat(var(--image-count, 1), 1fr); gap: 10px; margin-top: 22px; }
.dialog-image-wrap { position: relative; overflow: hidden; min-height: 250px; background: #e9e7e1; border-radius: 12px; }
.dialog-image-wrap img { width: 100%; height: 100%; object-fit: contain; display: block; }
.dialog-image-wrap span { position: absolute; top: 10px; left: 10px; color: #fff; background: rgba(25,26,24,.76); border-radius: 999px; padding: 5px 9px; font-size: 9px; font-weight: 800; }
.detail-section { padding: 22px 0; border-bottom: 1px solid var(--line); }
.detail-section:last-child { border: 0; padding-bottom: 0; }
.detail-section h3 { margin: 0 0 9px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.detail-section p { margin: 0; line-height: 1.75; color: #4f524e; }
.detail-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.meta-box { padding: 14px; background: #f3f1ec; border-radius: 10px; }
.meta-box span { display: block; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .1em; margin-bottom: 5px; }
.meta-box strong { font-size: 12px; }
.ai-workspace { padding: 22px; margin-top: 22px; background: #f1f4d5; border: 1px solid #dce45d; border-radius: 14px; }
.ai-workspace-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 17px; }
.ai-workspace h3 { margin: 0 0 5px; font: 600 20px Georgia, "Noto Serif TC", serif; }
.ai-workspace p { color: #646747; margin: 0; font-size: 11px; }
.draft-badge { flex: 0 0 auto; color: #65690e; background: rgba(255,255,255,.6); border-radius: 999px; padding: 5px 9px; font-size: 9px; font-weight: 900; letter-spacing: .1em; }
.ai-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ai-field { padding: 13px; background: rgba(255,255,255,.68); border-radius: 9px; }
.ai-field.wide { grid-column: 1 / -1; }
.ai-field label { display: block; color: #6d7147; font-size: 9px; font-weight: 900; letter-spacing: .1em; margin-bottom: 6px; }
.ai-field textarea, .ai-field input { width: 100%; padding: 0; min-height: auto; color: var(--ink); background: transparent; border: 0; border-radius: 0; font-size: 12px; line-height: 1.6; resize: vertical; }
.ai-field textarea:focus, .ai-field input:focus { outline: 0; box-shadow: none; }
.ai-confirm-row { display: flex; justify-content: flex-end; gap: 9px; margin-top: 15px; }
.confirm-ai { color: #fff; background: var(--ink); border: 0; border-radius: 999px; padding: 10px 15px; font-size: 11px; font-weight: 900; cursor: pointer; }
.cancel-ai { background: transparent; border: 0; padding: 10px; font-size: 11px; font-weight: 800; cursor: pointer; }
.original-lock { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-size: 10px; font-weight: 800; margin-top: 8px; }

@media (max-width: 850px) {
  .record-grid { grid-template-columns: repeat(2, 1fr); }
  .hero { padding-left: 0; padding-right: 0; }
  .time-chip { width: 140px; height: 140px; }
}

@media (max-width: 620px) {
  .app-shell { width: min(100% - 24px, 1180px); }
  .topbar { height: 74px; }
  .brand small { display: none; }
  .hero { min-height: 290px; padding: 45px 5px; }
  .hero h1 { font-size: 42px; }
  .hero p { font-size: 13px; max-width: 240px; }
  .time-chip { display: none; }
  .capture-card { border-radius: 17px; padding: 23px 17px; }
  .capture-heading { display: block; }
  .mode-switch { width: fit-content; margin: 20px 0 0 46px; }
  .drop-grid.compare-mode { grid-template-columns: 1fr; }
  .drop-zone { min-height: 225px; }
  .tag-list { padding-left: 0; }
  .note-meta span:first-child { display: none; }
  .note-meta { justify-content: flex-end; }
  .advanced-fields, .detail-meta, .ai-fields { grid-template-columns: 1fr; }
  .ai-field.wide { grid-column: auto; }
  .capture-footer { align-items: stretch; flex-direction: column; }
  .save-status { justify-content: center; }
  .primary-button { width: 100%; }
  .library-section { padding-top: 80px; }
  .library-heading { align-items: stretch; flex-direction: column; }
  .search-wrap { width: 100%; }
  .record-grid { grid-template-columns: 1fr; }
  .record-media { height: 220px; }
  .dialog-images { grid-template-columns: 1fr; }
  .dialog-image-wrap { min-height: 210px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

/* Compact capture flow */
.compact-hero {
  min-height: 112px;
  padding: 20px 3%;
}
.compact-hero h1 br { display: none; }
.compact-hero h1 { font-size: clamp(30px, 3.7vw, 46px); }
.compact-hero p { margin-top: 8px; font-size: 13px; }
.compact-hero .eyebrow { margin-bottom: 8px; }
.compact-hero .time-chip { width: 88px; height: 88px; }
.compact-hero .time-chip strong { font-size: 26px; }
.compact-hero .time-icon { display: none; }

.topbar { height: 72px; }
.capture-card { position: relative; padding: 24px; }
.capture-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr);
  gap: 34px;
  align-items: start;
}
.capture-left, .capture-right { min-width: 0; }
.capture-right {
  padding-left: 32px;
  border-left: 1px solid var(--line);
}
.capture-right .form-section:first-child { padding-top: 0; }
.capture-right .form-section { padding-top: 15px; }
.capture-right .section-label { margin-bottom: 10px; }
.capture-right textarea { min-height: 92px; }
.capture-card .drop-zone { min-height: 292px; }
.capture-card .drop-grid { margin-top: 18px; }
.capture-card .tag-list { padding-left: 46px; gap: 6px; }
.capture-card .tag-button { padding: 7px 10px; font-size: 11px; }
.capture-card .advanced-panel { margin-top: 12px; }
.capture-card .advanced-panel summary { padding: 12px 2px; }
.capture-card .capture-footer { padding-top: 13px; }

.more-tags-panel { margin: 10px 0 0 46px; }
.more-tags-panel summary {
  width: fit-content;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.tag-groups { display: grid; gap: 12px; margin-top: 12px; }
.tag-group h4 {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .12em;
}
.tag-group-list { display: flex; flex-wrap: wrap; gap: 6px; }

.capture-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  font-size: 20px;
  cursor: pointer;
}
.capture-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(25, 26, 24, .56);
  backdrop-filter: blur(5px);
}
.capture-overlay .capture-card {
  width: min(1100px, 100%);
  max-height: calc(100vh - 44px);
  overflow: auto;
}
.capture-overlay .capture-close { display: block !important; }

.toast { max-width: calc(100% - 30px); }
.toast-actions { display: flex; align-items: center; gap: 2px; margin-left: 8px; }
.toast-actions[hidden] { display: none; }
.toast-actions button {
  color: #fff;
  background: transparent;
  border: 0;
  border-left: 1px solid rgba(255,255,255,.18);
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}
.toast-actions button:hover { color: var(--lime); }

.record-grid { grid-template-columns: repeat(4, 1fr); gap: 15px; }
.record-media { height: 145px; }
.record-body { padding: 13px 14px 10px; }
.record-body h3 { font-size: 15px; margin-bottom: 5px; }
.record-note { height: 20px; -webkit-line-clamp: 1; font-size: 11px; }
.record-tags { min-height: 22px; margin-top: 9px; }
.record-tags .mini-tag:nth-child(n+4) { display: none; }
.record-actions { padding: 0 10px 10px; }

@media (max-width: 1050px) {
  .capture-layout { grid-template-columns: minmax(0, 1fr) minmax(330px, .9fr); gap: 24px; }
  .capture-right { padding-left: 24px; }
  .record-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 760px) {
  .compact-hero { min-height: 245px; padding-top: 40px; padding-bottom: 40px; }
  .capture-layout { grid-template-columns: 1fr; gap: 0; }
  .capture-right { padding: 0; border-left: 0; }
  .capture-right .form-section:first-child { padding-top: 32px; }
  .capture-card .drop-zone { min-height: 225px; }
  .capture-card .tag-list { padding-left: 0; }
  .more-tags-panel { margin-left: 0; }
  .record-grid { grid-template-columns: 1fr; }
  .record-media { height: 210px; }
  .capture-overlay { padding: 10px; }
  .capture-overlay .capture-card { max-height: calc(100vh - 20px); }
  .toast { align-items: flex-start; border-radius: 15px; flex-wrap: wrap; }
  .toast-actions { width: 100%; justify-content: flex-end; margin-left: 34px; }
  .top-nav-button { display: none; }
}

/* Analytics */
.analytics-section { padding: 30px 0 110px; scroll-margin-top: 20px; }
.analytics-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 25px;
  padding: 35px 0 28px;
  border-top: 1px solid var(--line);
}
.analytics-heading .eyebrow { margin-bottom: 8px; }
.analytics-heading h2 { margin: 0; font: 600 38px/1.1 Georgia, "Noto Serif TC", serif; }
.analytics-heading p { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.data-badge { flex: 0 0 auto; padding: 8px 12px; background: #e8e6df; border-radius: 999px; font-size: 10px; font-weight: 800; }

.answer-grid { display: grid; grid-template-columns: 1.55fr .72fr .72fr; gap: 12px; margin-bottom: 18px; }
.answer-card {
  position: relative;
  min-height: 170px;
  padding: 22px;
  overflow: hidden;
  color: #fff;
  background: var(--ink);
  border-radius: 16px;
}
.answer-card.answer-metric {
  min-height: 0;
  color: var(--ink);
  background: #fffefa;
  border: 1px solid var(--line);
  box-shadow: 0 6px 22px rgba(36,35,29,.035);
}
.answer-number { position: absolute; right: 14px; top: 7px; opacity: .15; font: 700 55px Georgia, serif; }
.answer-card h3 { position: relative; margin: 0 0 18px; font: 600 18px Georgia, "Noto Serif TC", serif; }
.answer-content { position: relative; font-size: 12px; line-height: 1.65; }
.answer-content strong { display: block; font-size: 24px; line-height: 1.2; margin-bottom: 5px; }
.metric-label { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.metric-content { margin-top: 20px; font-size: 11px; line-height: 1.55; }
.metric-content strong { display: block; margin-bottom: 5px; font: 600 24px/1.1 Georgia, "Noto Serif TC", serif; }

.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.analysis-threshold-hint {
  grid-column: 1 / -1;
  margin: 0;
  padding: 10px 0;
  color: var(--muted);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}
.progressive-analysis[hidden], #outcomeComparisonPanel[hidden] { display: none !important; }
.expanded-analysis {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.expanded-analysis > .wide { grid-column: 1 / -1; }
.analytics-panel {
  padding: 22px;
  background: var(--card);
  border: 1px solid rgba(25,26,24,.1);
  border-radius: 16px;
  box-shadow: 0 8px 25px rgba(36,35,29,.035);
}
.analytics-panel.wide { grid-column: 1 / -1; }
.analytics-panel > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.analytics-panel > header span { color: var(--accent); font-size: 9px; font-weight: 900; letter-spacing: .13em; }
.analytics-panel > header h3 { margin: 4px 0 0; font: 600 20px Georgia, "Noto Serif TC", serif; }
.analytics-panel > header small { color: var(--muted); font-size: 9px; }
.analysis-empty { padding: 25px; color: var(--muted); background: #f4f2ed; border-radius: 10px; text-align: center; font-size: 11px; line-height: 1.6; }
.analysis-empty.compact { padding: 12px; text-align: left; }
.checklist-tool { margin-top: 18px; border-top: 3px solid var(--ink); }

.ranking-list { display: grid; gap: 9px; }
.ranking-row { display: grid; grid-template-columns: 115px 1fr 42px; align-items: center; gap: 12px; }
.ranking-label { font-size: 11px; font-weight: 700; }
.ranking-track { height: 9px; overflow: hidden; background: #ebe9e3; border-radius: 999px; }
.ranking-fill { height: 100%; min-width: 3px; background: var(--accent); border-radius: 999px; }
.source-count {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  text-decoration: underline;
  cursor: pointer;
}
.data-badge.source-count {
  color: var(--ink);
  background: #e8e6df;
  text-decoration: none;
  padding: 8px 12px;
}

.comparison-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.comparison-table th, .comparison-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.comparison-table th { color: var(--muted); font-size: 9px; letter-spacing: .08em; }
.comparison-table td:first-child { font-weight: 800; }
.comparison-table button { margin: 2px 5px 2px 0; }

.effect-list, .candidate-list { display: grid; gap: 10px; }
.effect-item, .candidate-item {
  padding: 13px;
  background: #f5f3ee;
  border-radius: 10px;
}
.effect-item strong, .candidate-item strong { display: block; margin-bottom: 5px; font-size: 12px; }
.effect-item p, .candidate-item p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.effect-meta, .candidate-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 9px; }
.confirm-rule-button {
  border: 0;
  border-radius: 999px;
  padding: 8px 11px;
  color: #fff;
  background: var(--ink);
  font-size: 9px;
  font-weight: 900;
  cursor: pointer;
}

.comparison-gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 13px; }
.comparison-analysis-card { padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.comparison-images { display: grid; grid-template-columns: 1fr 1fr; height: 165px; overflow: hidden; background: #e9e7e1; border-radius: 9px; }
.comparison-images img { width: 100%; height: 100%; object-fit: cover; }
.comparison-images img + img { border-left: 2px solid #fff; }
.comparison-analysis-card h4 { margin: 10px 0 5px; font: 600 15px Georgia, "Noto Serif TC", serif; }
.comparison-analysis-card p { margin: 3px 0; color: var(--muted); font-size: 10px; line-height: 1.5; }

.similar-filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.similar-filters select, .similar-filters input, .analytics-select-label select {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  background: #f7f5f0;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 11px;
}
.analytics-select-label span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 800; }
.case-search-panel {
  grid-column: 1 / -1;
  order: 1;
  padding: 20px;
  background: #fffefa;
  border: 1px solid var(--line);
  border-radius: 15px;
}
.case-search-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.case-search-heading span, .analysis-summary-panel > header span, .checklist-tool > header span {
  color: var(--accent);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .13em;
}
.case-search-heading h3, .analysis-summary-panel > header h3, .checklist-tool > header h3 {
  margin: 4px 0 0;
  font: 600 19px Georgia, "Noto Serif TC", serif;
}
.basic-filters { grid-template-columns: minmax(240px, 1.6fr) repeat(2, minmax(150px, 1fr)) auto; }
.advanced-filter-button, .clear-filter-button {
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
}
.advanced-filter-button[aria-expanded="true"] { color: #fff; background: var(--ink); }
.advanced-filters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: -5px 0 14px;
  padding: 12px;
  background: #f4f2ed;
  border-radius: 10px;
}
.advanced-filters[hidden] { display: none; }
.advanced-filters input, .advanced-filters select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  background: #fffefa;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 11px;
}
.filter-summary {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
}
.filter-summary > strong { flex: 0 0 auto; font-size: 11px; }
.active-filter-chips { display: flex; flex: 1; flex-wrap: wrap; gap: 6px; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  color: #474942;
  background: #efede7;
  border: 0;
  border-radius: 999px;
  font-size: 9px;
  cursor: pointer;
}
.filter-chip b { font-size: 12px; line-height: 1; }
.clear-filter-button { height: 30px; margin-left: auto; border-color: var(--line); }
.similar-case-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.similar-case-card {
  display: flex;
  min-width: 0;
  height: 245px;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  color: var(--ink);
  text-align: left;
  background: #f6f4ef;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
}
.similar-case-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.similar-case-media { position: relative; display: block; height: 145px; flex: 0 0 145px; overflow: hidden; background: #dfddd6; }
.similar-case-media img { width: 100%; height: 100%; object-fit: cover; }
.similar-case-media > b {
  position: absolute;
  right: 7px;
  top: 7px;
  padding: 5px 7px;
  color: #fff;
  background: rgba(25,26,24,.82);
  border-radius: 999px;
  font-size: 8px;
}
.similar-case-placeholder {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  padding: 18px;
  color: #77786f;
  font: 600 13px/1.45 Georgia, "Noto Serif TC", serif;
  text-align: center;
}
.similar-case-body { display: flex; min-height: 0; flex: 1; flex-direction: column; padding: 10px; }
.similar-case-body > strong, .similar-case-note {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.similar-case-body > strong { margin-bottom: 5px; font-size: 11px; }
.similar-case-note { color: var(--muted); font-size: 9px; }
.similar-case-tags { display: flex; gap: 5px; margin-top: auto; overflow: hidden; }
.similar-case-tags i {
  overflow: hidden;
  padding: 4px 6px;
  color: #54564f;
  background: #e8e5de;
  border-radius: 999px;
  font-size: 8px;
  font-style: normal;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.compact-result-empty { grid-column: 1 / -1; margin: 0; padding: 14px 0; color: var(--muted); font-size: 10px; }
.analysis-bottom-row {
  grid-column: 1 / -1;
  order: 2;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(250px, .65fr);
  gap: 14px;
  align-items: start;
}
.analysis-summary-panel, .checklist-tool {
  padding: 18px;
  background: #f5f3ee;
  border: 1px solid var(--line);
  border-radius: 13px;
}
.analysis-summary-panel > header, .checklist-tool > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.analysis-summary-panel > header small { color: var(--muted); font-size: 9px; }
.checklist-tool { margin-top: 0; border-top: 3px solid var(--ink); }
.checklist-prompt { padding-top: 12px; color: var(--muted); font-size: 10px; }
.checklist-result { margin-top: 12px; }
#analysisThresholdHint { order: 0; }
#expandedAnalytics { order: 3; }
.source-case-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.source-case {
  min-width: 0;
  padding: 11px;
  text-align: left;
  background: #f5f3ee;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
}
.source-case:hover { border-color: var(--accent); }
.source-case strong { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; }
.source-case span { color: var(--muted); font-size: 9px; }
.checklist-list { margin: 0; padding-left: 18px; color: #4f524e; font-size: 11px; line-height: 1.75; }
.problem-action-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.problem-action-table th, .problem-action-table td { padding: 12px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.problem-action-table th { color: var(--muted); font-size: 9px; letter-spacing: .08em; }
.problem-action-table td:first-child { font-weight: 800; }
.recorded-state { color: var(--green); font-weight: 800; }
.unrecorded-state { color: var(--muted); }

.source-dialog-list { display: grid; gap: 8px; padding-top: 18px; }
.source-dialog-item { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 12px; background: #f5f3ee; border-radius: 9px; }
.source-dialog-item button { border: 0; background: transparent; color: var(--accent); font-size: 10px; font-weight: 900; cursor: pointer; }

.case-editor { padding-top: 22px; }
.case-editor h3 { margin: 0 0 6px; font: 600 20px Georgia, "Noto Serif TC", serif; }
.case-editor > p { margin: 0 0 16px; color: var(--muted); font-size: 11px; }
.case-field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.case-field { display: block; }
.case-field.wide { grid-column: 1 / -1; }
.case-field > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .07em; }
.case-field input, .case-field select, .case-field textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  background: #f7f5f0;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 11px;
}
.case-field textarea { min-height: 70px; }
.case-check { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 11px; font-weight: 700; }
.case-save-row { display: flex; justify-content: flex-end; margin-top: 16px; }
.case-save-button { border: 0; border-radius: 999px; padding: 10px 15px; color: #fff; background: var(--accent); font-size: 11px; font-weight: 900; cursor: pointer; }

@media (max-width: 760px) {
  .analytics-heading { align-items: flex-start; flex-direction: column; }
  .answer-grid, .analytics-grid, .comparison-gallery, .expanded-analysis { grid-template-columns: 1fr; }
  .analytics-panel.wide { grid-column: auto; }
  .similar-filters, .advanced-filters { grid-template-columns: 1fr 1fr; }
  .basic-filters input { grid-column: 1 / -1; }
  .filter-summary { align-items: flex-start; flex-wrap: wrap; }
  .active-filter-chips { order: 3; width: 100%; flex-basis: 100%; }
  .similar-case-grid { grid-template-columns: 1fr 1fr; }
  .similar-case-card { height: 220px; }
  .similar-case-media { height: 125px; flex-basis: 125px; }
  .analysis-bottom-row { grid-template-columns: 1fr; }
  .source-case-grid { grid-template-columns: 1fr 1fr; }
  .case-field-grid { grid-template-columns: 1fr; }
  .case-field.wide { grid-column: auto; }
  .ranking-row { grid-template-columns: 95px 1fr 35px; }
}

@media (min-width: 761px) and (max-width: 1120px) {
  .similar-case-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
