:root {
  --ink: #1d1e19;
  --muted: #77786d;
  --paper: #f4f0e8;
  --paper-deep: #e9e3d8;
  --line: rgba(29, 30, 25, 0.13);
  --green: #a8c36a;
  --green-deep: #6f8c32;
  --orange: #dd704d;
  --white: #fffdf8;
  --shadow: 0 20px 60px rgba(55, 50, 35, 0.08);
  font-family: "Aptos", "Segoe UI", "Noto Sans TC", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(168, 195, 106, 0.18), transparent 28rem),
    radial-gradient(circle at 92% 34%, rgba(221, 112, 77, 0.11), transparent 24rem),
    var(--paper);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

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

.app-shell { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 0 34px 32px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 92px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--ink); border-radius: 50%; font-size: 23px; line-height: 1; }
.brand strong { display: block; font-size: 14px; letter-spacing: 0.01em; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; }
.topbar-meta { display: flex; align-items: center; gap: 9px; }
.status-badge { display: inline-flex; align-items: center; gap: 7px; min-height: 28px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; letter-spacing: 0.04em; }
.status-badge.good { color: #55702c; border-color: rgba(111, 140, 50, 0.35); background: rgba(168, 195, 106, 0.16); }
.status-badge.warn { color: #9a4c35; border-color: rgba(221, 112, 77, 0.32); background: rgba(221, 112, 77, 0.1); }
.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.good .status-dot { background: var(--green-deep); box-shadow: 0 0 0 3px rgba(111, 140, 50, 0.12); }
.warn .status-dot { background: var(--orange); }

.hero { max-width: 820px; padding: 88px 0 74px; }
.eyebrow, .section-kicker { color: var(--green-deep); font-size: 10px; font-weight: 700; letter-spacing: 0.19em; }
.eyebrow { display: flex; align-items: center; gap: 9px; }
.eyebrow span { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); }
.hero h1 { margin: 21px 0 20px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(50px, 7.3vw, 88px); font-weight: 400; letter-spacing: -0.065em; line-height: 0.96; }
.hero h1 em { color: var(--green-deep); font-style: italic; }
.hero-copy { max-width: 595px; margin: 0; color: #5d5e55; font-size: 15px; line-height: 1.85; }
.hero-stats { display: flex; gap: 48px; margin-top: 39px; }
.hero-stats div { display: flex; align-items: baseline; gap: 10px; }
.hero-stats strong { font-family: Georgia, serif; font-size: 22px; font-weight: 400; }
.hero-stats span { color: var(--muted); font-size: 11px; letter-spacing: 0.08em; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(285px, 0.85fr); gap: 20px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 3px; background: rgba(255, 253, 248, 0.76); box-shadow: var(--shadow); }
.composer-panel { padding: 32px 34px 27px; }
.side-column { display: grid; gap: 20px; }
.journey-panel, .system-panel { padding: 30px 29px; }
.panel-heading { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 29px; }
.panel-heading.compact { margin-bottom: 25px; }
.panel-heading h2, .activity-heading h2 { margin: 7px 0 0; font-family: Georgia, serif; font-size: 26px; font-weight: 400; letter-spacing: -0.035em; }
.panel-index { color: var(--muted); font-family: Georgia, serif; font-size: 21px; }

.access-panel { margin: -5px 0 24px; padding: 14px; border: 1px solid rgba(221, 112, 77, 0.28); background: rgba(221, 112, 77, 0.07); }
.access-panel label, .notebook-url-wrap label { display: block; margin-bottom: 7px; color: #7d4c3d; font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.access-panel p { margin: 8px 0 0; color: var(--muted); font-size: 11px; }
.inline-input { display: flex; gap: 8px; }

.field-block { margin-bottom: 23px; }
.field-block > label, .two-column label { display: block; margin-bottom: 9px; color: #5f6056; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
input, select { width: 100%; border: 1px solid rgba(29, 30, 25, 0.17); border-radius: 2px; outline: none; background: rgba(255, 253, 248, 0.82); color: var(--ink); transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease; }
input:focus, select:focus { border-color: var(--green-deep); box-shadow: 0 0 0 3px rgba(168, 195, 106, 0.2); background: var(--white); }
input { height: 47px; padding: 0 14px; font-size: 14px; }
select { height: 45px; padding: 0 12px; font-size: 13px; }
.url-input-wrap { position: relative; display: flex; align-items: center; }
.url-input-wrap input { padding-right: 82px; padding-left: 40px; }
.url-prefix { position: absolute; left: 14px; color: var(--green-deep); font-size: 19px; }
.preview-button { position: absolute; right: 7px; height: 33px; padding: 0 11px; border: 0; border-radius: 2px; color: var(--ink); background: var(--paper-deep); font-size: 11px; font-weight: 700; }
.preview-button:hover { background: var(--green); }
.field-help { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.preview-card { display: grid; grid-template-columns: 130px 1fr; gap: 15px; margin: -2px 0 24px; padding: 10px; border: 1px solid var(--line); background: var(--paper); }
.preview-image-wrap { position: relative; overflow: hidden; min-height: 73px; background: var(--paper-deep); }
.preview-image-wrap img { display: block; width: 100%; height: 100%; min-height: 73px; object-fit: cover; }
.preview-play { position: absolute; right: 8px; bottom: 7px; display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; color: var(--white); background: var(--orange); font-size: 9px; }
.preview-details { align-self: center; min-width: 0; }
.preview-label { color: var(--green-deep); font-size: 9px; font-weight: 700; letter-spacing: 0.17em; }
.preview-details h3 { overflow: hidden; margin: 5px 0 4px; font-size: 14px; font-weight: 700; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.preview-details p { margin: 0; color: var(--muted); font-size: 11px; }

.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.callout { display: flex; gap: 12px; margin: 2px 0 23px; padding: 13px 14px; border-left: 3px solid var(--green-deep); background: rgba(168, 195, 106, 0.13); }
.callout-icon { display: grid; place-items: center; flex: 0 0 auto; width: 27px; height: 27px; border-radius: 50%; color: var(--green-deep); background: rgba(168, 195, 106, 0.3); }
.callout strong { display: block; font-size: 12px; }
.callout p { margin: 4px 0 0; color: #6c735e; font-size: 11px; line-height: 1.5; }

.study-box { margin: 3px 0 24px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.check-row { display: flex; align-items: flex-start; gap: 11px; padding: 17px 2px; cursor: pointer; }
.check-row input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.fake-check { position: relative; flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; border: 1px solid rgba(29, 30, 25, 0.28); border-radius: 2px; background: var(--white); }
.check-row input:checked + .fake-check { border-color: var(--green-deep); background: var(--green-deep); }
.check-row input:checked + .fake-check::after { position: absolute; top: 1px; left: 5px; width: 5px; height: 10px; border: solid white; border-width: 0 2px 2px 0; content: ""; transform: rotate(45deg); }
.check-row strong, .check-row small { display: block; }
.check-row strong { font-size: 13px; }
.check-row small { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.notebook-url-wrap { padding: 0 0 17px 30px; }
.notebook-url-wrap input { height: 41px; font-size: 12px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 12px; border: 0; border-radius: 2px; font-weight: 700; transition: transform 160ms ease, background 160ms ease, opacity 160ms ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: 0.55; transform: none; }
.button-primary { width: 100%; min-height: 52px; padding: 0 20px; color: #fffdf8; background: var(--ink); font-size: 13px; letter-spacing: 0.04em; }
.button-primary:hover { background: #3e4630; }
.button-arrow { color: var(--green); font-size: 20px; font-weight: 400; }
.button-small { flex: 0 0 auto; padding: 0 13px; color: var(--white); background: var(--ink); font-size: 11px; }
.legal-note { margin: 19px 0 0; color: var(--muted); font-size: 10px; line-height: 1.65; }

.journey-list { position: relative; display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.journey-list::before { position: absolute; top: 19px; bottom: 19px; left: 14px; border-left: 1px dashed rgba(29, 30, 25, 0.18); content: ""; }
.journey-item { position: relative; display: grid; grid-template-columns: 29px 1fr; gap: 11px; align-items: start; padding: 0 0 24px; }
.journey-item:last-child { padding-bottom: 4px; }
.journey-number { position: relative; z-index: 1; display: grid; place-items: center; width: 29px; height: 29px; border: 1px solid rgba(29, 30, 25, 0.18); border-radius: 50%; color: var(--muted); background: var(--white); font-family: Georgia, serif; font-size: 11px; }
.journey-item.active .journey-number { border-color: var(--green-deep); color: var(--green-deep); background: var(--green); }
.journey-item strong { display: block; padding-top: 4px; font-size: 12px; }
.journey-item small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.side-quote { display: flex; gap: 7px; margin-top: 25px; padding-top: 20px; border-top: 1px solid var(--line); }
.side-quote span { color: var(--orange); font-family: Georgia, serif; font-size: 32px; line-height: 0.7; }
.side-quote p { margin: 0; color: #65665d; font-family: Georgia, serif; font-size: 13px; font-style: italic; line-height: 1.55; }

.system-row { display: flex; justify-content: space-between; gap: 15px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 11px; }
.system-row span { color: var(--muted); }
.system-row strong { font-size: 11px; font-weight: 700; }
.system-message { margin: 15px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; }

.activity-section { padding: 73px 0 35px; }
.activity-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.text-button { border: 0; color: var(--green-deep); background: transparent; font-size: 11px; }
.text-button:hover { color: var(--ink); }
.text-button span { margin-left: 4px; font-size: 17px; }
.jobs-list { display: grid; gap: 10px; }
.empty-state { display: grid; place-items: center; min-height: 155px; border: 1px dashed rgba(29, 30, 25, 0.2); color: var(--muted); text-align: center; }
.empty-icon { display: block; margin-bottom: 8px; color: var(--green-deep); font-size: 28px; }
.empty-state strong { color: var(--ink); font-family: Georgia, serif; font-size: 17px; font-weight: 400; }
.empty-state p { margin: 6px 0 0; font-size: 11px; }
.job-card { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(160px, 0.8fr) auto; gap: 22px; align-items: center; padding: 18px 20px; border: 1px solid var(--line); background: rgba(255, 253, 248, 0.7); }
.job-main { min-width: 0; }
.job-title { overflow: hidden; margin: 0 0 7px; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.job-url { overflow: hidden; margin: 0; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.job-meta { display: flex; gap: 7px; align-items: center; color: var(--muted); font-size: 10px; }
.job-status { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 10px; font-weight: 700; }
.job-status .status-dot { width: 6px; height: 6px; }
.job-status.processing, .job-status.queued { color: #8a7332; }
.job-status.completed { color: var(--green-deep); }
.job-status.failed { color: #a24e38; }
.progress-track { overflow: hidden; height: 5px; border-radius: 999px; background: var(--paper-deep); }
.progress-fill { height: 100%; border-radius: inherit; background: var(--green-deep); transition: width 300ms ease; }
.job-stage { margin-top: 7px; color: var(--muted); font-size: 10px; }
.job-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 7px; }
.job-action { display: inline-flex; align-items: center; min-height: 29px; padding: 0 9px; border: 1px solid var(--line); color: var(--ink); background: transparent; font-size: 10px; text-decoration: none; white-space: nowrap; }
.job-action:hover { border-color: var(--green-deep); background: rgba(168, 195, 106, 0.15); }
.job-error { grid-column: 1 / -1; margin: -5px 0 0; padding-top: 10px; border-top: 1px solid rgba(221, 112, 77, 0.2); color: #a24e38; font-size: 10px; line-height: 1.5; }

.toast { position: fixed; right: 26px; bottom: 24px; z-index: 5; max-width: 360px; padding: 13px 16px; border: 1px solid var(--line); color: var(--ink); background: var(--white); box-shadow: var(--shadow); font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity 180ms ease, transform 180ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(221, 112, 77, 0.35); color: #984934; }
.footer { display: flex; justify-content: space-between; gap: 20px; padding-top: 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; }

@media (max-width: 760px) {
  .app-shell { padding: 0 18px 24px; }
  .topbar { min-height: 76px; }
  .brand small { display: none; }
  .topbar-meta { gap: 5px; }
  .status-badge { padding: 0 8px; font-size: 9px; }
  .hero { padding: 62px 0 55px; }
  .hero h1 { font-size: clamp(48px, 14vw, 72px); }
  .hero-copy { font-size: 13px; }
  .hero-stats { gap: 18px; }
  .hero-stats strong { font-size: 18px; }
  .hero-stats span { font-size: 9px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .composer-panel { padding: 25px 20px 22px; }
  .journey-panel, .system-panel { padding: 25px 20px; }
  .job-card { grid-template-columns: 1fr; gap: 12px; }
  .job-actions { justify-content: start; }
  .footer { display: block; line-height: 1.8; }
  .footer span { display: block; }
}

@media (max-width: 450px) {
  .two-column { grid-template-columns: 1fr; gap: 0; }
  .preview-card { grid-template-columns: 100px 1fr; }
  .topbar-meta #mode-badge { display: none; }
}
