:root {
  --ink: #1a2420;
  --ink-soft: #3d4a44;
  --muted: #6b7872;
  --paper: #f3f0e8;
  --paper-2: #e8e4d8;
  --surface: rgba(255, 252, 245, 0.92);
  --jade: #1f6b5a;
  --jade-deep: #0f453a;
  --brass: #b08a3c;
  --brass-soft: #d4b56a;
  --line: rgba(26, 36, 32, 0.12);
  --danger: #9b3b2e;
  --ok: #1f6b5a;
  --running: #8a6a1f;
  --shadow: 0 18px 50px rgba(26, 36, 32, 0.08);
  --radius: 14px;
  --font-display: "Instrument Serif", "Noto Serif TC", serif;
  --font-body: "Noto Sans TC", sans-serif;
  --font-serif: "Noto Serif TC", "Instrument Serif", serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(31, 107, 90, 0.12), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(176, 138, 60, 0.14), transparent 50%),
    linear-gradient(180deg, #efece3 0%, var(--paper) 40%, #ebe6da 100%);
  line-height: 1.65;
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.topbar,
main {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: linear-gradient(135deg, var(--jade), var(--brass));
  box-shadow: 0 0 0 3px rgba(31, 107, 90, 0.15);
  animation: pulse-mark 2.8s ease-in-out infinite;
}

@keyframes pulse-mark {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.85; }
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}

.settings-btn,
.btn-primary,
.btn-ghost {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.settings-btn {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.875rem;
}

.settings-btn:hover {
  border-color: var(--jade);
  color: var(--jade-deep);
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.hero {
  padding: 1.5rem 0 3rem;
  animation: fade-up 0.7s ease both;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.eyebrow {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--jade);
  font-weight: 600;
}

.brand-hero {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(3rem, 8vw, 5.2rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.hero-lead {
  margin: 0.85rem 0 2rem;
  max-width: 34rem;
  font-size: 1.1rem;
  color: var(--ink-soft);
}

.scenario {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem 1.7rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  animation: fade-up 0.8s ease 0.1s both;
}

.scenario::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--jade), var(--brass));
}

.scenario-label {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass);
  font-weight: 600;
  margin-bottom: 0.55rem;
}

.scenario-title {
  margin: 0 0 0.85rem;
  font-family: var(--font-serif);
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 600;
  line-height: 1.35;
}

.scenario-body {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1rem;
}

.scenario-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--muted);
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
  animation: fade-up 0.8s ease 0.2s both;
}

.btn-primary {
  background: var(--jade-deep);
  color: #f7f4ec;
  border-radius: 999px;
  padding: 0.85rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(15, 69, 58, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--jade);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.85rem 1.35rem;
  font-size: 0.95rem;
}

.btn-ghost:hover {
  border-color: var(--ink-soft);
  color: var(--ink);
}

.hidden {
  display: none !important;
}

.workspace {
  animation: fade-up 0.55s ease both;
  padding-top: 0.5rem;
}

.workspace-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.workspace-header h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 600;
}

.progress-wrap {
  min-width: min(280px, 100%);
}

.progress-bar {
  height: 6px;
  background: var(--paper-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--jade), var(--brass-soft));
  transition: width 0.45s ease;
}

.progress-label {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
}

.layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.todo-panel,
.stream-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.todo-panel {
  padding: 1.2rem 1.15rem;
  position: sticky;
  top: 1rem;
}

.todo-panel h3 {
  margin: 0 0 1rem;
  font-family: var(--font-serif);
  font-size: 1.05rem;
}

.todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.todo-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 0.65rem;
  align-items: start;
  padding: 0.7rem 0.65rem;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.todo-item.active {
  background: rgba(31, 107, 90, 0.08);
  border-color: rgba(31, 107, 90, 0.22);
}

.todo-item.done {
  opacity: 0.85;
}

.todo-status {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  margin-top: 2px;
  color: var(--muted);
  background: #fff;
}

.todo-item.active .todo-status {
  border-color: var(--running);
  color: var(--running);
  animation: spin-soft 1.2s linear infinite;
}

.todo-item.done .todo-status {
  border-color: var(--ok);
  background: var(--ok);
  color: #fff;
  animation: none;
}

@keyframes spin-soft {
  to { transform: rotate(360deg); }
}

.todo-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.4;
}

.todo-desc {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

.stream-panel {
  padding: 1.25rem 1.35rem 1.6rem;
  min-height: 420px;
}

.stream-steps {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.step-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  background: rgba(255, 255, 255, 0.55);
  animation: step-in 0.4s ease both;
}

@keyframes step-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.step-card.running {
  border-color: rgba(138, 106, 31, 0.35);
  box-shadow: 0 0 0 3px rgba(176, 138, 60, 0.08);
}

.step-card.done {
  border-color: rgba(31, 107, 90, 0.25);
}

.step-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.step-head h4 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
}

.step-badge {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.step-badge.running {
  color: var(--running);
  border-color: rgba(138, 106, 31, 0.35);
  background: rgba(176, 138, 60, 0.1);
}

.step-badge.done {
  color: var(--ok);
  border-color: rgba(31, 107, 90, 0.3);
  background: rgba(31, 107, 90, 0.08);
}

.step-badge.error {
  color: var(--danger);
  border-color: rgba(155, 59, 46, 0.35);
  background: rgba(155, 59, 46, 0.08);
}

.step-body {
  color: var(--ink-soft);
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.step-body h1,
.step-body h2,
.step-body h3,
.step-body h4 {
  font-family: var(--font-serif);
  color: var(--ink);
  margin: 1rem 0 0.4rem;
  line-height: 1.35;
}

.step-body h1 { font-size: 1.2rem; }
.step-body h2 { font-size: 1.1rem; }
.step-body h3 { font-size: 1.02rem; }

.step-body p { margin: 0.45rem 0; }
.step-body ul,
.step-body ol {
  margin: 0.4rem 0;
  padding-left: 1.25rem;
}
.step-body li { margin: 0.25rem 0; }
.step-body a {
  color: var(--jade-deep);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.step-body code {
  font-size: 0.88em;
  background: var(--paper-2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.step-body strong { color: var(--ink); font-weight: 600; }

.search-hits {
  margin-top: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.search-hit {
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  background: rgba(31, 107, 90, 0.05);
  border: 1px solid rgba(31, 107, 90, 0.12);
}

.search-hit a {
  font-weight: 600;
  color: var(--jade-deep);
  text-decoration: none;
  font-size: 0.9rem;
}

.search-hit a:hover {
  text-decoration: underline;
}

.search-hit p {
  margin: 0.3rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.typing::after {
  content: "▍";
  animation: blink 0.9s step-end infinite;
  color: var(--jade);
  margin-left: 2px;
}

@keyframes blink {
  50% { opacity: 0; }
}

.final-answer {
  margin-top: 1.35rem;
  padding: 1.35rem 1.4rem;
  border-radius: 12px;
  border: 1px solid rgba(31, 107, 90, 0.28);
  background:
    linear-gradient(135deg, rgba(31, 107, 90, 0.07), transparent 45%),
    rgba(255, 255, 255, 0.7);
  animation: fade-up 0.55s ease both;
}

.final-answer h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.35rem;
}

.final-body {
  margin-top: 0.85rem;
  color: var(--ink-soft);
  font-size: 0.98rem;
}

.disclaimer {
  margin: 1.2rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--muted);
}

.modal {
  border: none;
  border-radius: 16px;
  padding: 0;
  background: transparent;
  max-width: min(480px, calc(100vw - 2rem));
}

.modal::backdrop {
  background: rgba(26, 36, 32, 0.45);
  backdrop-filter: blur(4px);
}

.modal-card {
  background: #fffcf5;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.4rem 1.45rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.modal-card h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.35rem;
}

.modal-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.modal-card label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.modal-card input,
.modal-card select,
.modal-card textarea {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  background: #fff;
  resize: vertical;
}

.modal-card input:focus,
.modal-card select:focus,
.modal-card textarea:focus {
  outline: 2px solid rgba(31, 107, 90, 0.35);
  border-color: var(--jade);
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.25rem;
}
