/* notebook.css — Notebook Atlas */

:root {
  --bg: #f2efe8;
  --bg-paper: #fbf8f1;
  --bg-soft: #efe7da;
  --bg-panel: #ffffffcc;
  --ink: #1e2a3b;
  --ink-soft: #4e5d72;
  --ink-muted: #6f7f95;
  --line: #c9bfae;
  --line-strong: #a89b83;
  --accent: #2f6e6a;
  --accent-soft: #d4ece8;
  --accent-2: #cc7d2c;
  --danger: #8f3e2e;

  --radius-md: 14px;
  --radius-lg: 20px;

  --font-title: "Bricolage Grotesque", "Noto Sans TC", sans-serif;
  --font-body: "Noto Sans TC", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;

  --shadow-card: 0 16px 30px rgba(63, 49, 23, 0.1);
  --shadow-panel: 0 20px 60px rgba(42, 34, 20, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(60% 70% at 9% 8%, #d7ece9 0%, rgba(215, 236, 233, 0) 62%),
    radial-gradient(45% 55% at 92% 96%, #f3dec1 0%, rgba(243, 222, 193, 0) 58%),
    var(--bg);
  overflow: hidden;
}

.notebook-mode {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr;
  isolation: isolate;
}

.bg-orb {
  position: absolute;
  z-index: -1;
  pointer-events: none;
  border-radius: 50%;
  filter: blur(30px);
}

.orb-a {
  width: 320px;
  height: 320px;
  top: -120px;
  right: -90px;
  background: rgba(56, 132, 124, 0.22);
}

.orb-b {
  width: 260px;
  height: 260px;
  left: -100px;
  bottom: -80px;
  background: rgba(215, 154, 84, 0.2);
}

.header {
  padding: 18px 28px;
  border-bottom: 1px solid rgba(148, 131, 103, 0.3);
  background: linear-gradient(180deg, rgba(255, 252, 245, 0.94) 0%, rgba(248, 242, 232, 0.82) 100%);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.header-main {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  color: var(--accent);
  border: 1px solid rgba(47, 110, 106, 0.25);
  background: linear-gradient(145deg, #e8f6f3 0%, #dcece9 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}

.header-title {
  margin: 0;
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 730;
  letter-spacing: 0.01em;
}

.header-sub {
  margin: 2px 0 0;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.header-count {
  margin-left: 8px;
  min-width: 86px;
  padding: 8px 10px;
  border-radius: 12px;
  text-align: center;
  border: 1px solid rgba(168, 155, 131, 0.45);
  background: #fffaf0;
}

#total-count {
  display: block;
  line-height: 1;
  font-family: var(--font-title);
  font-size: 1.34rem;
  font-weight: 710;
  color: #244f4b;
}

.count-label {
  display: block;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: #5e6d82;
}

.header-actions {
  display: flex;
  align-items: center;
}

.toolbar {
  padding: 14px 28px 16px;
  border-bottom: 1px solid rgba(148, 131, 103, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: rgba(251, 248, 241, 0.78);
}

.search-bar {
  display: flex;
  align-items: center;
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid rgba(146, 127, 96, 0.34);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(54, 43, 21, 0.08);
}

.search-icon {
  width: 40px;
  text-align: center;
  color: #74859d;
}

.search-input {
  border: 0;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 0.92rem;
  color: var(--ink);
  padding: 10px 14px 10px 0;
  font-family: var(--font-body);
}

.search-input::placeholder {
  color: #8a98ac;
}

.toolbar-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

#results-meta {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(125, 106, 74, 0.27);
  background: #fffaf2;
  font-family: var(--font-mono);
}

.toolbar-hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid rgba(115, 101, 76, 0.4);
  background: #fff;
  color: #3b4f68;
}

.pairs-container {
  padding: 26px 28px 32px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  align-content: start;
}

.pairs-container::-webkit-scrollbar {
  width: 10px;
}

.pairs-container::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
  background-color: rgba(108, 91, 62, 0.35);
}

.pair-card {
  display: flex;
  flex-direction: column;
  min-height: 220px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(250, 245, 236, 0.94) 100%);
  border: 1px solid rgba(161, 141, 109, 0.3);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: transform 170ms ease, box-shadow 170ms ease;
}

.pair-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 38px rgba(66, 50, 22, 0.18);
}

.pair-original {
  padding: 18px 18px 14px;
  font-size: 0.88rem;
  color: #5d6d86;
  line-height: 1.62;
  border-bottom: 1px dashed rgba(157, 142, 113, 0.4);
}

.pair-original::before {
  content: "SRC";
  display: inline-block;
  margin-right: 8px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid rgba(112, 136, 167, 0.28);
  background: #eef4fd;
  color: #61789a;
  font-size: 0.62rem;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
}

.pair-translation {
  padding: 16px 18px 20px;
  font-size: 1rem;
  line-height: 1.68;
  color: #22344b;
  font-weight: 500;
}

.pair-translation::before {
  content: "TR";
  display: inline-block;
  margin-right: 8px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid rgba(47, 110, 106, 0.25);
  background: var(--accent-soft);
  color: #2f6e6a;
  font-size: 0.62rem;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
}

.pair-actions {
  margin-top: auto;
  padding: 12px 14px;
  border-top: 1px solid rgba(157, 142, 113, 0.3);
  background: rgba(247, 239, 226, 0.7);
}

.ai-ask-btn {
  width: 100%;
  border: 1px solid rgba(47, 110, 106, 0.36);
  border-radius: 999px;
  padding: 9px 12px;
  background: linear-gradient(120deg, #e4f4f1 0%, #f6f0e2 100%);
  color: #215653;
  font-family: var(--font-title);
  font-size: 0.86rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}

.ai-ask-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(44, 107, 100, 0.2);
  filter: saturate(1.05);
}

.empty-state {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #6f7f95;
  text-align: center;
}

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid rgba(161, 141, 109, 0.4);
  background: radial-gradient(circle at 32% 25%, #ffffff 0%, #f3ecdf 70%);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
}

.empty-hint {
  color: #7e8ea4;
  font-size: 0.82rem;
  line-height: 1.65;
}

.settings-panel {
  margin: 16px 28px 0;
  background: var(--bg-panel);
  border: 1px solid rgba(159, 143, 115, 0.36);
  border-radius: 16px;
  box-shadow: var(--shadow-panel);
  padding: 20px;
  display: grid;
  gap: 14px;
}

.settings-panel.hidden,
.modal.hidden {
  display: none !important;
}

.settings-header h2 {
  margin: 0;
  font-family: var(--font-title);
  font-size: 1.1rem;
}

.settings-group {
  display: grid;
  gap: 7px;
}

.settings-group label {
  font-size: 0.82rem;
  color: #5f6d82;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.9rem;
  color: var(--ink);
}

.input-with-btn {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.input-with-btn input[type="text"],
.input-with-btn input[type="password"],
.input-with-btn select {
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(145, 126, 97, 0.32);
  background: #fff;
  color: var(--ink);
  font-family: var(--font-body);
  padding: 9px 12px;
}

.settings-hint {
  margin: 0;
  color: #7f8c9f;
  font-size: 0.76rem;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

#settings-status {
  color: #1e6b57;
  font-size: 0.82rem;
}

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 9px 14px;
  font-family: var(--font-title);
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(130deg, #2f6e6a 0%, #3b8075 100%);
  color: #ecfffb;
  border-color: rgba(47, 110, 106, 0.45);
}

.btn-secondary {
  background: #f3ece0;
  color: #3d4f67;
  border-color: rgba(153, 136, 110, 0.42);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(33, 25, 14, 0.46);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 20;
}

.modal-content {
  position: relative;
  width: min(920px, 92vw);
  max-height: 86vh;
  overflow: auto;
  border-radius: 18px;
  background: #fffaf0;
  border: 1px solid rgba(155, 137, 106, 0.45);
  box-shadow: 0 26px 60px rgba(39, 30, 16, 0.35);
  padding: 20px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(145, 126, 97, 0.35);
  border-radius: 50%;
  background: #fff;
  color: #3f4f66;
  cursor: pointer;
}

.modal-header h3 {
  margin: 0 0 12px;
  font-family: var(--font-title);
  font-size: 1.08rem;
}

.modal-source-box,
.modal-result-box {
  border: 1px solid rgba(153, 137, 111, 0.3);
  border-radius: 12px;
  background: #fff;
  padding: 14px;
}

.modal-source-box {
  margin-bottom: 10px;
  color: #40526a;
}

.modal-source-box small {
  display: inline-block;
  margin-top: 7px;
  color: #687892;
}

.modal-result-box {
  line-height: 1.72;
}

.loading-spinner {
  color: #3b5f89;
}

.ai-progress {
  margin-bottom: 12px;
}

.ai-progress-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 8px;
}

.ai-step {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 30px;
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid rgba(148, 132, 107, 0.32);
  background: #f8f2e8;
  color: #667487;
  font-size: 0.75rem;
}

.ai-step.is-active {
  border-color: rgba(47, 110, 106, 0.5);
  background: #dff0ed;
  color: #225854;
  font-weight: 680;
}

.ai-step.is-done {
  border-color: rgba(47, 110, 106, 0.42);
  background: #eef8f6;
  color: #2f6e6a;
}

.ai-stream-box {
  border-radius: 12px;
  border: 1px dashed rgba(145, 125, 95, 0.34);
  background: #fffdf8;
  padding: 12px;
}

.ai-stream-placeholder {
  margin-bottom: 7px;
  color: #7a8799;
  font-size: 0.8rem;
}

.ai-stream-content {
  min-height: 32px;
  color: #2a3a51;
}

@media (max-width: 920px) {
  .header,
  .toolbar,
  .pairs-container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-bar {
    width: 100%;
  }

  .pairs-container {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .settings-panel {
    margin: 12px 16px 0;
  }

  .input-with-btn {
    grid-template-columns: 1fr;
  }
}

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