:root {
  color-scheme: light;
  --bg: #f3f0e8;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #172126;
  --muted: #647178;
  --line: #d7d2c6;
  --accent: #24515a;
  --accent-2: #b85c38;
  --ok: #2f6f4e;
  --warn: #9a6423;
  --danger: #9f3a3a;
  --shadow: 0 10px 24px rgba(32, 36, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Noto Sans TC", system-ui, sans-serif;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 18px;
}

h3 {
  margin-bottom: 6px;
  font-size: 17px;
}

.status-pill,
.owner-badge,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.status-pill.ok {
  color: var(--ok);
}

.status-pill.error {
  color: var(--danger);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(280px, 360px) minmax(340px, 1fr);
  gap: 14px;
  max-width: 1440px;
  margin: 0 auto;
  align-items: start;
}

.app-shell.detail-mode .workspace {
  grid-template-columns: minmax(0, 960px);
  justify-content: center;
}

.details-panel {
  display: none;
}

.app-shell.detail-mode .control-panel,
.app-shell.detail-mode .plans-panel,
.app-shell.detail-mode .timeline-panel {
  display: none;
}

.app-shell.detail-mode .details-panel {
  display: block;
  width: 100%;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading.compact {
  margin-top: 18px;
  margin-bottom: 8px;
}

.detail-heading {
  justify-content: start;
}

.back-button {
  flex: 0 0 auto;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.field select,
.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
}

.summary-box,
.list-block,
.announcements {
  color: var(--muted);
  font-size: 14px;
}

.summary-box {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.day-tabs {
  display: flex;
  gap: 8px;
  max-width: 100%;
  margin: -2px 0 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.day-tab {
  display: grid;
  gap: 2px;
  min-width: 76px;
  min-height: 52px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 7px 10px;
  text-align: left;
}

.day-tab span {
  font-weight: 800;
}

.day-tab small {
  color: var(--muted);
  font-size: 12px;
}

.day-tab.active {
  border-color: var(--accent);
  background: #eef6f3;
  color: var(--accent);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.plans-list,
.timeline {
  display: grid;
  gap: 10px;
}

.plan-filter-note {
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.plan-filter-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.plan-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 13px;
}

.plan-card.active {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.plan-meta,
.plan-description {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 12px;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.secondary-button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.danger-button {
  border-color: rgba(159, 58, 58, 0.35);
  background: #fff7f5;
  color: var(--danger);
}

.icon-button {
  width: 38px;
  padding: 0;
  border-color: var(--line);
  background: #fff;
  color: var(--accent);
  font-size: 20px;
}

.timeline-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  overflow: hidden;
}

.node-main {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 8px 12px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.node-main:hover,
.node-main.selected {
  background: #eef6f3;
}

.node-time {
  color: var(--accent);
  font-weight: 800;
}

.node-title {
  font-weight: 700;
}

.node-tags {
  grid-column: 2;
  color: var(--muted);
  font-size: 13px;
}

.node-quick-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 8px 12px;
}

.muted,
.empty-note {
  color: var(--muted);
}

.notice {
  border-left: 4px solid var(--accent-2);
  margin-bottom: 10px;
  padding: 8px 10px;
  background: #fff8ee;
  color: #5e3d24;
  border-radius: 0 8px 8px 0;
  font-size: 14px;
}

.override-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.override-row,
.fixed-row {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px;
}

.override-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.owner-tools {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.tool-disclosure {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.tool-disclosure h2,
.tool-disclosure p {
  margin: 0;
}

.tool-disclosure > div {
  min-width: 0;
}

.tool-disclosure button {
  flex: 0 0 auto;
}

.tool-disclosure p {
  color: var(--muted);
  font-size: 13px;
}

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

.owner-tool-form {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.owner-tool-form button {
  justify-self: stretch;
}

.owner-plan-head,
.owner-plan-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 62px 44px;
  gap: 8px;
  align-items: center;
}

.owner-plan-head {
  grid-template-columns: minmax(0, 1fr) 62px 44px;
  padding-left: 36px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.owner-plan-list {
  display: grid;
  gap: 8px;
}

.owner-plan-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.owner-plan-row.inactive {
  color: var(--muted);
}

.owner-plan-row input[type="checkbox"],
.owner-plan-row input[type="radio"] {
  width: auto;
  margin: 0;
}

.owner-plan-row input[type="number"] {
  width: 100%;
  min-width: 0;
  padding: 6px 7px;
}

.owner-plan-title {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 700;
}

.detail-title {
  margin-bottom: 6px;
  font-size: 20px;
}

.detail-actions,
.node-content-list,
.replacement-list,
.ai-search-panel,
.transport-details,
.notes-area {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.transport-details {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}

.transport-details p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.replacement-option {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.replacement-option button {
  justify-self: start;
}

.replacement-content-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.dish-tag {
  display: grid;
  gap: 2px;
  max-width: 100%;
  border: 1px solid rgba(36, 81, 90, 0.18);
  border-radius: 8px;
  background: #f6fbf8;
  color: var(--ink);
  padding: 7px 9px;
  font-size: 13px;
}

.dish-tag span,
.dish-tag small {
  color: var(--muted);
}

.dish-tag small {
  max-width: 280px;
}

.node-content-item {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.node-content-form {
  display: grid;
  gap: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fffaf0;
  padding: 10px;
}

.content-form-actions {
  display: flex;
  align-items: end;
}

.content-form-actions button {
  width: 100%;
}

.node-content-item.checked {
  background: #f7f7f3;
  color: var(--muted);
}

.node-content-item.checked strong {
  text-decoration: line-through;
}

.node-content-item p {
  margin-bottom: 0;
}

.content-item-head,
.content-links,
.content-sort-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.content-item-head {
  justify-content: space-between;
}

.content-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.content-sort-actions {
  margin-left: auto;
}

.personal-badge {
  border-color: rgba(47, 111, 78, 0.25);
  background: #f1faf4;
  color: var(--ok);
}

.icon-button.mini {
  width: 30px;
  min-height: 30px;
  font-size: 15px;
}

.icon-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.compact-button {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 13px;
}

.content-link-button {
  font: inherit;
}

.ai-search-form,
.ai-suggestion-list,
.ai-suggestion {
  display: grid;
  gap: 10px;
}

.ai-suggestion {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.ai-suggestion-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field.compact-field {
  margin-bottom: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent);
  padding: 8px 12px;
  text-decoration: none;
}

.map-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid rgba(36, 81, 90, 0.25);
  border-radius: 8px;
  background: #f6fbf8;
  color: var(--accent);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.detail-map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.small-text {
  color: var(--muted);
  font-size: 13px;
}

.locked-note {
  color: var(--warn);
  font-weight: 700;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(240px, 320px) 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

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

  .plan-card {
    grid-template-columns: 1fr;
  }

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