*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gold:      #c9a84c;
  --gold-l:    #e8c87a;
  --gold-d:    #a07830;
  --bg:        #fafaf8;
  --card:      #ffffff;
  --text:      #1a1a1a;
  --muted:     #888;
  --nav-h:     68px;
  --r:         16px;
  --sh:        0 4px 20px rgba(0,0,0,.08);
  --sh-lg:     0 8px 40px rgba(0,0,0,.14);
}

html, body {
  height: 100%; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0ebe3; color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  max-width: 390px;
  margin: 0 auto;
}

#landing, #welcome-screen, #app {
  max-width: 390px;
  margin: 0 auto;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── SCREENS ── */
.screen {
  display: none; position: absolute;
  inset: 0; bottom: var(--nav-h);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-top: calc(env(safe-area-inset-top) + 16px);
  padding-bottom: 70px;
  width: 100%;
}
.screen.active { display: block; }
.screen.chat-screen { display: none; flex-direction: column; }
.screen.chat-screen.active { display: flex; }

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: fixed; bottom: 0;
  left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 390px;
  height: var(--nav-h);
  background: #fff; border-top: 1px solid #f0ede4;
  box-shadow: 0 -4px 20px rgba(0,0,0,.06);
  display: flex; align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  border: none; background: none; cursor: pointer;
  padding: 8px 0; -webkit-tap-highlight-color: transparent;
  transition: transform .15s;
}
.nav-btn:active { transform: scale(.9); }
.nav-btn .nav-icon { font-size: 22px; }
.nav-btn .nav-label { font-size: 10px; color: var(--muted); font-weight: 500; transition: color .2s; }
.nav-btn.active .nav-label { color: var(--gold); }

/* ── HERO ── */
#hero-canvas {
  width: 100%; height: 52vw;
  max-height: 275px; min-height: 170px;
  background: #05071a; position: relative; overflow: hidden;
}
#hero-canvas canvas { display: block; }


/* ── SECTION HEADER ── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 8px;
}
.section-title { font-family: Georgia, serif; font-size: 17px; }

/* ── MIC BTN ── */
.mic-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--gold); background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; cursor: pointer; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent; transition: all .2s;
}
.mic-btn:active { transform: scale(.9); }
.mic-btn.listening { background: var(--gold); animation: pulse 1s ease-in-out infinite; }

@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(201,168,76,.4); }
  50%      { box-shadow: 0 0 0 12px rgba(201,168,76,0); }
}

/* ── VOICE ANSWER ── */
#voice-answer {
  display: none; margin: 0 16px 10px;
  padding: 12px 14px;
  background: #fffbf0; border: 1px solid #f0e4b0;
  border-radius: var(--r); font-size: 14px; line-height: 1.55;
}

/* ── PLACES GRID ── */
.places-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; padding: 0 16px 28px;
}
.place-card {
  background: var(--card); border-radius: var(--r);
  overflow: hidden; box-shadow: var(--sh); cursor: pointer;
  transition: transform .18s, box-shadow .18s;
  -webkit-tap-highlight-color: transparent;
}
.place-card:active { transform: scale(.97); box-shadow: var(--sh-lg); }
.place-card-img {
  height: 90px;
  background: linear-gradient(135deg,#f5f0e8,#e8dfc0);
  display: flex; align-items: center; justify-content: center;
}
.place-emoji { font-size: 36px; }
.place-card-body { padding: 10px 10px 12px; }
.place-card-name { font-size: 13px; font-weight: 600; line-height: 1.3; margin-bottom: 4px; }
.place-card-meta { display: flex; gap: 8px; font-size: 11px; margin-bottom: 3px; }
.place-rating { color: var(--gold-d); font-weight: 600; }
.place-dist { color: var(--muted); }
.place-card-addr { font-size: 11px; color: var(--muted); line-height: 1.3; }

/* ── MODAL ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 200;
  align-items: flex-end;
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  background: #fff; border-radius: 24px 24px 0 0;
  width: 100%; max-height: 80vh; overflow-y: auto;
  padding: 20px 20px 40px;
  animation: slide-up .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle { width: 40px; height: 4px; background: #ddd; border-radius: 2px; margin: 0 auto 16px; }
.modal-title { font-family: Georgia, serif; font-size: 20px; margin-bottom: 14px; }
.modal-story { font-size: 15px; line-height: 1.7; color: #333; }
.modal-close {
  margin-top: 20px; width: 100%; padding: 13px;
  border: 1.5px solid var(--gold); border-radius: var(--r);
  background: #fff; color: var(--gold-d); font-size: 15px; font-weight: 600; cursor: pointer;
}

/* ── PLANNER ── */
.planner-header { padding: 16px 16px 6px; }
.planner-title { font-family: Georgia, serif; font-size: 20px; margin-bottom: 4px; }
.planner-hint { font-size: 13px; color: var(--muted); }

.planner-input-row { display: flex; gap: 10px; padding: 10px 16px 14px; align-items: center; }
.planner-input {
  flex: 1; padding: 12px 16px;
  border: 1.5px solid #e8e4d8; border-radius: 14px;
  font-size: 15px; background: #fff; outline: none; transition: border-color .2s;
}
.planner-input:focus { border-color: var(--gold); }
.planner-input::placeholder { color: #bbb; }

.route-steps { padding: 0 16px 100px; }
.route-empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.route-empty-icon { font-size: 48px; margin-bottom: 12px; }
.route-empty p { font-size: 14px; line-height: 1.6; }
.route-loading { text-align: center; padding: 40px; color: var(--muted); font-size: 14px; }

.route-list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 12px;
  color: #4b4133;
  font-size: 13px;
  font-weight: 700;
}
.route-list-toolbar button {
  border: 1px solid var(--gold-l);
  background: #fffaf0;
  color: var(--gold-d);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.route-map-card {
  background: #fff;
  border: 1px solid #efe7cf;
  border-radius: 16px;
  overflow: hidden;
  margin: 4px 0 14px;
  box-shadow: 0 6px 22px rgba(80, 64, 34, 0.08);
}
.route-map-hidden { display: none; }
.route-map-card.route-map-active {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100%;
  max-width: 430px;
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.route-map-head {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: #fffaf0;
  border-bottom: 1px solid #efe7cf;
  font-size: 13px;
  font-weight: 700;
  color: #3b3325;
}
.route-map-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.route-map-head button {
  border: 1px solid var(--gold-l);
  background: #fff;
  color: var(--gold-d);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
}
#route-map {
  position: relative;
  width: 100%;
  height: min(58vh, 420px);
  min-height: 340px;
  background: #efe9dc;
}
.route-map-active #route-map {
  flex: 1;
  height: auto;
  min-height: 0;
}
.route-static-map {
  position: relative;
  overflow: hidden;
  background: #e7eadf;
}
.route-static-tile {
  position: absolute;
  width: 256px;
  height: 256px;
  user-select: none;
  -webkit-user-drag: none;
}
.route-static-line {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.route-static-line polyline {
  fill: none;
  stroke: #c9a84c;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  paint-order: stroke;
}
.route-static-marker {
  position: absolute;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid #fff;
  background: var(--gold);
  color: #fff;
  box-shadow: 0 4px 14px rgba(57, 43, 14, 0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  z-index: 3;
}
.route-static-marker-origin {
  background: #3f8f72;
}
.route-static-marker-active {
  background: #c9683a;
  box-shadow: 0 0 0 5px rgba(201, 104, 58, 0.22), 0 6px 18px rgba(57, 43, 14, 0.36);
  transform: translate(-50%, -50%) scale(1.12);
}
.route-map-story-status {
  padding: 10px 12px 12px;
  background: #fffaf0;
  border-top: 1px solid #efe7cf;
  color: var(--gold-d);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}
.route-map-marker {
  background: transparent;
  border: none;
}
.route-map-marker b {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid #fff;
  box-shadow: 0 4px 12px rgba(57, 43, 14, 0.28);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.route-step {
  display: flex; gap: 14px; padding: 14px 0;
  border-bottom: 1px solid #f0ede4; transition: background .2s;
}
.route-step.active {
  background: #fffbf0; border-radius: var(--r);
  padding: 14px 12px; margin: 0 -12px;
}
.route-step-num {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--gold); color: #fff;
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px;
}
.route-step-body { flex: 1; }
.route-step-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.route-step-meta { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.route-step-desc { font-size: 13px; color: #555; line-height: 1.5; margin-bottom: 8px; }
.route-tell-btn {
  font-size: 12px; color: var(--gold-d);
  background: #fffbf0; border: 1px solid var(--gold-l);
  border-radius: 8px; padding: 5px 10px; cursor: pointer;
}

.start-route-btn {
  display: none; position: fixed;
  bottom: calc(var(--nav-h) + 16px); left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, var(--gold), var(--gold-l));
  color: #fff; border: none; border-radius: 28px;
  padding: 14px 32px; font-size: 16px; font-weight: 700;
  cursor: pointer; box-shadow: 0 6px 24px rgba(201,168,76,.45);
  white-space: nowrap; align-items: center; gap: 8px; z-index: 50;
  -webkit-tap-highlight-color: transparent;
}
.start-route-btn:active { transform: translateX(-50%) scale(.96); }

/* ── TRANSLATOR ── */
.translator-screen { padding: 16px; padding-bottom: 24px; }
.translator-title { font-family: Georgia, serif; font-size: 20px; margin-bottom: 16px; padding-top: 4px; }

.lang-grid {
  display: grid; grid-template-columns: repeat(4,1fr);
  gap: 8px; margin-bottom: 20px;
}
.lang-btn {
  background: #fff; border: 1.5px solid #e8e4d8; border-radius: 12px;
  padding: 10px 6px; display: flex; flex-direction: column;
  align-items: center; gap: 4px; cursor: pointer; transition: all .18s;
  -webkit-tap-highlight-color: transparent;
}
.lang-btn:active { transform: scale(.93); }
.lang-btn.active { border-color: var(--gold); background: #fffbf0; }
.lang-flag { font-size: 22px; }
.lang-name { font-size: 10px; color: var(--muted); text-align: center; }
.lang-btn.active .lang-name { color: var(--gold-d); font-weight: 600; }

.translator-mic-wrap { display: flex; justify-content: center; gap: 14px; margin-bottom: 20px; }
.translator-mic-btn {
  width: 72px; height: 72px; border-radius: 50%;
  border: 3px solid var(--gold); background: #fff;
  font-size: 32px; cursor: pointer;
  box-shadow: 0 4px 20px rgba(201,168,76,.25); transition: all .2s;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.translator-mic-btn:active { transform: scale(.93); }
.translator-mic-btn.listening { background: var(--gold); animation: pulse 1s ease-in-out infinite; }
.translator-mic-btn.reply-ready {
  border-color: #3a7bc9;
  box-shadow: 0 4px 20px rgba(58,123,201,.2);
}
.translator-mic-btn.reply-ready.listening { background: #3a7bc9; }

.translator-block { background: #fff; border-radius: var(--r); box-shadow: var(--sh); margin-bottom: 12px; overflow: hidden; }
.translator-block-label {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .8px; padding: 10px 14px 0;
}
.translator-block-text { padding: 8px 14px 14px; font-size: 16px; line-height: 1.5; min-height: 52px; }

.speak-btn {
  display: none; align-items: center; gap: 6px;
  margin: 0 14px 14px; padding: 9px 16px;
  background: var(--gold); color: #fff;
  border: none; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.speak-btn:active { opacity: .85; }

.quick-phrases-title {
  font-size: 13px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px;
  margin-bottom: 10px; margin-top: 4px;
}
.quick-phrases { display: flex; flex-direction: column; gap: 8px; }
.quick-phrase-btn {
  background: #fff; border: 1px solid #e8e4d8; border-radius: 12px;
  padding: 11px 14px; text-align: left; font-size: 14px; color: var(--text);
  cursor: pointer; transition: all .15s; -webkit-tap-highlight-color: transparent;
}
.quick-phrase-btn:active { background: #fffbf0; border-color: var(--gold); }

/* ── CHAT ── */
.chat-header { padding: 16px 16px 8px; background: var(--bg); }
.chat-title { font-family: Georgia, serif; font-size: 20px; }

.chat-suggestions {
  display: flex; gap: 8px; padding: 0 16px 12px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.chat-suggestions::-webkit-scrollbar { display: none; }
.suggestion-chip {
  white-space: nowrap; padding: 7px 13px;
  border: 1px solid #e8e4d8; border-radius: 20px; background: #fff;
  font-size: 13px; color: var(--text); cursor: pointer; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent; transition: all .15s;
}
.suggestion-chip:active { background: #fffbf0; border-color: var(--gold); }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 8px 16px 16px;
  display: flex; flex-direction: column; gap: 16px;
  -webkit-overflow-scrolling: touch;
}
.chat-msg {
  max-width: 82%; padding: 11px 14px; border-radius: 16px;
  font-size: 15px; line-height: 1.5; word-wrap: break-word;
  margin-bottom: 8px;
}
.chat-msg-user { background: var(--gold); color: #fff; align-self: flex-end; border-bottom-right-radius: 5px; }
.chat-msg-assistant { background: #fff; color: var(--text); align-self: flex-start; box-shadow: var(--sh); border-bottom-left-radius: 5px; }

.chat-input-row {
  display: flex; gap: 10px; padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid #f0ede4; align-items: center;
}
.chat-text-input {
  flex: 1; padding: 12px 16px;
  border: 1.5px solid #e8e4d8; border-radius: 22px;
  font-size: 15px; background: #fff; outline: none; transition: border-color .2s;
}
.chat-text-input:focus { border-color: var(--gold); }
.chat-text-input::placeholder { color: #bbb; }
.chat-send-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--gold); border: none; color: #fff; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; -webkit-tap-highlight-color: transparent;
  transition: transform .15s;
}
.chat-send-btn:active { transform: scale(.9); }
.chat-stop-btn {
  display: none; height: 44px; padding: 0 14px; border-radius: 22px;
  border: none; background: #c9683a; color: #fff;
  font-size: 13px; font-weight: 700; cursor: pointer; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.chat-stop-btn:active { opacity: .85; }

/* ── LOADING DOTS ── */
.loading-dots { display: flex; gap: 5px; align-items: center; justify-content: center; padding: 8px 0; }
.loading-dots span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--gold);
  animation: dot 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: .2s; }
.loading-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%,80%,100% { transform: scale(.7); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }

::-webkit-scrollbar { width: 0; background: transparent; }

@keyframes marco-wave {
  0%,100% { transform: rotate(0deg); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}
.marco-talking {
  animation: marco-wave 0.5s ease-in-out 3;
}
