:root {
  --bg: #f7f6f2;
  --paper: #fffdfa;
  --ink: #22211d;
  --muted: #6d6a61;
  --line: #d9d5ca;
  --accent: #3e766f;
  --soft: #ece9df;
  --danger: #a43d2f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Noto Sans TC", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button,
a.primary-link {
  min-height: 40px;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #faf9f5;
  padding: 28px 22px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--ink);
  font-weight: 800;
}

.brand h1,
.topbar h2,
.next-card h3 {
  margin: 0;
}

.eyebrow,
.section-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.project-nav {
  display: grid;
  gap: 8px;
  margin-bottom: 28px;
}

.nav-item,
.quiet-button,
.primary-link,
.day-tab,
.accordion-head,
.ticket-head,
.image-thumb {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
}

.nav-item {
  padding: 12px 14px;
  text-align: left;
}

.nav-item.active {
  border-color: var(--ink);
  font-weight: 700;
}

.side-card,
.cloud-panel,
.trip-controls,
.next-card,
.travel-day-tickets,
.info-card {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 8px;
  padding: 16px;
}

.side-card {
  margin-top: 18px;
}

.workspace {
  width: min(1180px, 100%);
  padding: 28px 34px 72px;
}

.topbar,
.cloud-panel,
.trip-controls,
.panel-head {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.topbar {
  margin-bottom: 18px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.quiet-button,
.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
}

.primary-link {
  width: fit-content;
  margin-top: 12px;
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  font-weight: 700;
}

.cloud-panel {
  margin-bottom: 18px;
}

.trip-controls {
  margin-bottom: 16px;
}

.trip-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.new-project-form {
  display: contents;
}

.editor-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  margin-bottom: 16px;
  padding: 14px 16px;
}

.editor-panel summary,
.inline-editor summary {
  cursor: pointer;
  font-weight: 700;
}

.inline-editor {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.editor-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.editor-grid input,
.editor-grid select,
.editor-grid textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  resize: vertical;
}

.editor-grid select[multiple] {
  min-height: 112px;
}

.wide-field {
  grid-column: 1 / -1;
}

.danger-button {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.trip-controls input {
  min-height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px 10px;
  color: var(--ink);
}

.day-tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 0 18px;
}

.day-tab {
  min-width: 116px;
  padding: 12px 14px;
  text-align: left;
}

.day-tab strong,
.day-tab span {
  display: block;
}

.day-tab.active {
  border-color: var(--ink);
  background: #fff;
}

.card-stack,
.ticket-list,
.pretrip-grid {
  display: grid;
  gap: 12px;
}

.accordion-card,
.ticket-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  overflow: hidden;
}

.accordion-card.active,
.ticket-card.active {
  border-left: 4px solid var(--accent);
  box-shadow: 0 8px 22px rgba(35, 34, 30, 0.06);
}

.accordion-head,
.ticket-head {
  display: grid;
  width: 100%;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  border: 0;
  background: transparent;
  padding: 16px;
  text-align: left;
}

.ticket-head {
  grid-template-columns: minmax(0, 1fr) auto;
}

.accordion-head strong,
.ticket-head strong {
  display: block;
  margin-bottom: 5px;
  font-size: 1.05rem;
}

.accordion-head small,
.ticket-head small,
.time {
  color: var(--muted);
}

.card-type,
.status-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
  padding: 5px 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.accordion-body,
.ticket-body {
  display: none;
  padding: 0 16px 16px 102px;
}

.ticket-body {
  padding-left: 16px;
}

.accordion-card.active .accordion-body,
.ticket-card.active .ticket-body {
  display: block;
}

.option-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.option-list p {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 10px;
}

.next-card {
  margin-bottom: 18px;
}

.travel-day-tickets {
  margin-top: 18px;
}

.offline-panel {
  align-items: center;
  background: #f7f5ef;
  border: 1px solid var(--line);
  border-left: 4px solid #55786f;
  border-radius: 6px;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin: 18px 0;
  padding: 16px;
}

.offline-panel h3,
.offline-panel p {
  margin: 0;
}

.offline-panel h3 {
  margin-bottom: 6px;
}

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

.offline-warning {
  color: #8b4b20;
  font-weight: 700;
  margin-top: 8px;
}

.panel-head.compact {
  align-items: flex-start;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.image-thumb {
  border-radius: 8px;
  padding: 8px;
  text-align: left;
}

.image-thumb img {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.image-thumb span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.86rem;
}

.pretrip-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.info-card strong,
.info-card p,
.info-card small {
  display: block;
  margin: 0 0 8px;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(32, 31, 28, 0.72);
}

.image-modal.open {
  display: grid;
}

.image-modal-panel {
  width: min(760px, 96vw);
  max-height: 92vh;
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.image-modal img {
  width: 100%;
  display: block;
  border-radius: 6px;
}

.image-modal button {
  margin-top: 10px;
}

.readonly-layout {
  display: block;
}

.readonly-standalone .workspace {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 22px 14px 70px;
}

.readonly-standalone .next-card {
  border: 0;
  background: transparent;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}

.comment-box {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 16px;
}

.comment-head,
.comment-item div {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.comment-head span,
.comment-item time,
.muted-text {
  color: var(--muted);
  font-size: 0.86rem;
}

.comment-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.comment-item {
  background: #fbfaf7;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
}

.comment-item p {
  margin: 6px 0 0;
}

.comment-form {
  display: grid;
  gap: 8px;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  margin-top: 12px;
}

.comment-form input,
.comment-form textarea {
  border: 1px solid var(--line);
  border-radius: 3px;
  font: inherit;
  padding: 10px;
}

.comment-form textarea {
  resize: vertical;
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 18px 14px;
  }

  .project-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .nav-item {
    padding: 10px 8px;
    text-align: center;
  }

  .workspace {
    padding: 18px 14px 60px;
  }

  .topbar,
  .cloud-panel,
  .trip-controls,
  .panel-head,
  .offline-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
  }

  .offline-actions {
    justify-content: stretch;
  }

  .top-actions button,
  .quiet-button,
  .primary-link {
    width: 100%;
  }

  .trip-controls {
    display: grid;
  }

  .editor-grid {
    grid-template-columns: 1fr;
  }

  .comment-form {
    grid-template-columns: 1fr;
  }

  .accordion-head {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .accordion-head .card-type {
    grid-column: 2;
    width: fit-content;
  }

  .accordion-body {
    padding: 0 14px 14px;
  }

  .pretrip-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  body {
    font-size: 15px;
  }

  .brand h1 {
    font-size: 1.2rem;
  }

  .project-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .day-tab {
    min-width: 104px;
  }

  .accordion-head,
  .ticket-head {
    gap: 10px;
    padding: 14px;
  }

  .image-grid {
    grid-template-columns: 1fr;
  }
}
