:root {
  color-scheme: light;
  --paper: #f7f4ee;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #1f2523;
  --muted: #65706c;
  --line: #ddd7cb;
  --green: #26715f;
  --green-soft: #dbeee8;
  --amber: #b46b18;
  --amber-soft: #f5e3c8;
  --red: #a13c3c;
  --red-soft: #f1dada;
  --blue: #2f6592;
  --blue-soft: #dce9f3;
  --plum: #6d5275;
  --plum-soft: #eadfed;
  --shadow: 0 14px 32px rgba(46, 43, 37, 0.1);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family:
    "Microsoft JhengHei",
    "PingFang TC",
    "Noto Sans TC",
    system-ui,
    sans-serif;
  letter-spacing: 0;
  background:
    linear-gradient(180deg, rgba(247, 244, 238, 0.96), rgba(247, 244, 238, 1)),
    var(--paper);
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.icon-sprite {
  display: none;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-block: 10px 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(1.85rem, 4vw, 3rem);
  line-height: 1.12;
}

h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.35;
}

h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.45;
}

.subhead {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.icon-button,
.install-button,
.secondary-button,
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  box-shadow: none;
}

.icon-button {
  width: 42px;
  padding: 0;
}

.install-button,
.secondary-button,
.copy-button {
  padding: 0 13px;
}

.icon-button:hover,
.install-button:hover,
.secondary-button:hover,
.copy-button:hover {
  border-color: #b9b0a1;
  background: #fff8ed;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.status-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  color: var(--muted);
  font-size: 0.93rem;
}

.status-band > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-card {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.summary-toggle {
  display: block;
  width: 100%;
  min-height: 112px;
  padding: 16px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.summary-toggle:hover {
  background: #fffaf1;
}

.summary-toggle:focus-visible {
  outline: 3px solid rgba(38, 113, 95, 0.22);
  outline-offset: -3px;
}

.summary-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.summary-card .summary-label {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
}

.summary-arrow {
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 160ms ease;
}

.summary-card.open .summary-arrow {
  transform: rotate(225deg);
}

.summary-value {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
  line-height: 1;
}

.summary-note {
  display: block;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.summary-menu {
  border-top: 1px solid #ebe4d9;
  background: #fbf8f2;
  padding: 6px 0;
}

.summary-menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.summary-menu li {
  display: grid;
  gap: 3px;
  padding: 10px 16px;
  border-bottom: 1px solid #ebe4d9;
}

.summary-menu li:last-child {
  border-bottom: 0;
}

.summary-menu-title {
  color: var(--ink);
  font-weight: 700;
  line-height: 1.35;
}

.summary-menu-meta,
.summary-menu-empty {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.summary-menu-empty {
  padding: 12px 16px;
}

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

.segmented-control {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(76px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ebe5db;
}

.segment {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  white-space: nowrap;
}

.segment.active {
  background: var(--surface-strong);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(36, 31, 24, 0.12);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(360px, 100%);
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.search-box svg {
  color: var(--muted);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  min-width: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 22px;
  align-items: start;
}

.dashboard-section {
  min-width: 0;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 700;
}

.timeline,
.item-list {
  display: grid;
  gap: 12px;
}

.schedule-item,
.tracking-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.schedule-item {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  min-height: 92px;
  padding: 14px;
}

.schedule-time {
  color: var(--green);
  font-weight: 800;
}

.schedule-item p,
.tracking-card p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.94rem;
}

.tracking-card {
  padding: 14px;
}

.card-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge.urgent {
  background: var(--red-soft);
  color: var(--red);
}

.badge.today {
  background: var(--green-soft);
  color: var(--green);
}

.badge.risk {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.normal {
  background: var(--blue-soft);
  color: var(--blue);
}

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

.meta {
  min-height: 62px;
  padding: 10px;
  border: 1px solid #ebe4d9;
  border-radius: 8px;
  background: #fbf8f2;
}

.meta span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  margin-bottom: 3px;
}

.meta strong {
  display: block;
  font-size: 0.9rem;
  line-height: 1.35;
}

.notion-field-link {
  color: var(--green);
  text-decoration: none;
  border-bottom: 1px solid rgba(38, 113, 95, 0.35);
}

.notion-field-link:hover {
  border-bottom-color: var(--green);
}

.copy-button {
  width: 100%;
  margin-top: 12px;
  color: var(--green);
  font-weight: 700;
}

.empty-state {
  min-height: 116px;
  padding: 18px;
  border: 1px dashed #c7bfb3;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.6);
}

.connection-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(320px, 0.9fr);
  gap: 22px;
  margin-top: 28px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fdfaf4;
}

.connection-panel p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.api-form {
  display: grid;
  gap: 8px;
  align-content: start;
}

.api-form label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.api-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.api-row input {
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  outline: 0;
  background: var(--surface-strong);
}

.api-row input:focus,
.search-box:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(38, 113, 95, 0.14);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 10;
  width: min(420px, calc(100% - 32px));
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  padding: 12px 14px;
  background: #1f2523;
  color: #fff;
  text-align: center;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1120px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .topbar {
    display: grid;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .status-band,
  .toolbar,
  .connection-panel {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .segmented-control {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-box {
    width: 100%;
  }

  .schedule-item,
  .meta-grid,
  .api-row {
    grid-template-columns: 1fr;
  }

  .schedule-item {
    min-height: auto;
  }
}
