:root {
  --navy: #0f2a3f;
  --navy-2: #163b52;
  --teal: #2a8b93;
  --sand: #f6efe3;
  --sand-2: #efe4d0;
  --coral: #ff8a65;
  --ink: #1c2b33;
  --ink-soft: #5a6b73;
  --card-bg: #ffffff;
  --border: #e6dcc8;
  --shadow: 0 2px 10px rgba(15, 42, 63, 0.08);

  --cat-transport: #3b7ea1;
  --cat-food: #d97b3f;
  --cat-attraction: #2a8b93;
  --cat-hotel: #7a5ea8;

  color-scheme: light;
  background: var(--sand);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sand: #0b1c28;
    --sand-2: #122735;
    --ink: #eef2f4;
    --ink-soft: #a9b8c0;
    --card-bg: #142a38;
    --border: #1f3b4d;
    --shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
    background: var(--sand);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--sand);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sticky-top {
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fdf9f0;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 20px 18px;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wave-mark {
  color: var(--coral);
  flex-shrink: 0;
  opacity: 0.9;
}

.app-header h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: #cfe0e6;
  letter-spacing: 0.03em;
}

.tabbar {
  display: flex;
  gap: 2px;
  background: var(--navy-2);
  padding: 0 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }

.tab-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: #b9cbd3;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 12px 12px 10px;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  cursor: pointer;
}

.tab-btn.active {
  color: #fff;
  border-bottom-color: var(--coral);
}

main {
  flex: 1;
  padding: 16px 16px 40px;
  outline: none;
}

.day-theme {
  font-size: 1rem;
  font-weight: 700;
  margin: 4px 2px 16px;
  color: var(--ink);
}
.day-theme .date {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-soft);
  margin-top: 2px;
}

.timeline {
  position: relative;
  padding-left: 18px;
  border-left: 2px solid var(--border);
}

.item {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 0 0 12px;
  box-shadow: var(--shadow);
}

.item::before {
  content: "";
  position: absolute;
  left: -23px;
  top: 16px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot-color, var(--teal));
  border: 2px solid var(--sand);
}

.item[data-cat="transport"] { --dot-color: var(--cat-transport); }
.item[data-cat="food"] { --dot-color: var(--cat-food); }
.item[data-cat="attraction"] { --dot-color: var(--cat-attraction); }
.item[data-cat="hotel"] { --dot-color: var(--cat-hotel); }

.item-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.item-time {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--dot-color, var(--teal));
  letter-spacing: 0.01em;
}

.item-cat-icon { font-size: 0.85rem; }

.item-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 4px 0 4px;
  color: var(--ink);
}

.item-detail {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--ink-soft);
  white-space: pre-line;
}

.item-tip {
  margin-top: 8px;
  font-size: 0.8rem;
  background: var(--sand-2);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--ink);
}
.item-tip::before { content: "💡 "; }

.map-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--teal);
  text-decoration: none;
  border: 1px solid var(--teal);
  border-radius: 999px;
  padding: 4px 10px;
}

/* Korean phrases tab */
.scenario-group {
  margin-bottom: 20px;
}
.scenario-title {
  font-size: 0.92rem;
  font-weight: 700;
  margin: 0 0 8px 2px;
  color: var(--teal);
}
.phrase-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.phrase-text { flex: 1; min-width: 0; }
.phrase-ko { font-size: 1rem; font-weight: 700; color: var(--ink); }
.phrase-ro { font-size: 0.76rem; color: var(--ink-soft); margin-top: 1px; }
.phrase-zh { font-size: 0.8rem; color: var(--ink-soft); margin-top: 3px; }

.speak-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--teal);
  color: #fff;
  font-size: 1.05rem;
  cursor: pointer;
}
.speak-btn:active { transform: scale(0.94); }
.speak-btn[disabled] { opacity: 0.35; cursor: not-allowed; }

.tts-note {
  font-size: 0.76rem;
  color: var(--ink-soft);
  background: var(--sand-2);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 16px;
  line-height: 1.6;
}

/* Info tab */
.info-section {
  margin-bottom: 22px;
}
.info-section h2 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--teal);
  margin: 0 0 10px 2px;
}
.info-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px 14px;
  box-shadow: var(--shadow);
}
.info-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }
.info-row .label { color: var(--ink-soft); }
.info-row .value { font-weight: 700; color: var(--ink); text-align: right; }

.info-list, .checklist {
  list-style: none;
  margin: 0;
  padding: 0;
}
.info-list li, .checklist li {
  position: relative;
  padding: 10px 0 10px 20px;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
}
.info-list li:last-child, .checklist li:last-child { border-bottom: none; }
.info-list li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 17px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--coral);
}
.checklist li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  width: 13px;
  height: 13px;
  border: 2px solid var(--teal);
  border-radius: 4px;
}

.info-text {
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--ink);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.offline-hint {
  text-align: center;
  font-size: 0.72rem;
  color: var(--ink-soft);
  padding: 4px 20px 22px;
  margin: 0;
}
