:root {
  --bg: #FAF6F0;
  --surface: #FFFFFF;
  --surface-warm: #FFF9F0;
  --surface-point: #FFFDF7;
  --border: #E8DDD0;
  --border-strong: #D9C8B6;

  --text: #231C18;
  --text-secondary: #5F534A;
  --text-muted: #847569;

  --primary: #C84B31;
  --primary-dark: #A53821;
  --primary-soft: #FDEEE9;

  --jade: #2E6B56;
  --jade-soft: #EAF4F0;

  --amber-bg: #FFF5E4;
  --amber-border: #F2D3A0;
  --amber-text: #8A4D0D;

  --shadow-sm: 0 2px 8px rgba(45, 28, 16, 0.05);
  --shadow-md: 0 6px 20px rgba(45, 28, 16, 0.08);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-pill: 999px;

  --font-sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "PingFang TC", "Noto Sans TC", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Yu Gothic", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-tc: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Hiragino Sans", sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

button,
a {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: 100%;
  max-width: 520px;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 246, 240, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 12px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
  mix-blend-mode: multiply;
}

.brand-text {
  min-width: 0;
}

.brand-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text);
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.2;
}

/* 4-Language Switcher */
.lang-switcher {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px;
  background: #EFE7DC;
  padding: 3px;
  border-radius: 12px;
}

.lang-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  min-height: 36px;
  padding: 6px 4px;
  border-radius: 9px;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.lang-btn[aria-selected="true"] {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(35, 28, 24, 0.12);
}

.lang-btn:focus-visible,
.chip:focus-visible,
.btn:focus-visible,
.point-expand-btn:focus-visible,
.reset-inline-btn:focus-visible,
.search-clear-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Filters & Search */
.filter-panel {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 0 10px;
}

.search-row {
  padding: 0 14px 8px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.search-box:focus-within {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(200, 75, 49, 0.12);
}

.search-icon {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}

.search-input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 38px;
  padding: 6px 36px 6px 34px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 1.35;
  outline: none;
}

.search-input::placeholder {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.search-clear-btn {
  position: absolute;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: #E4D8CA;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.search-clear-btn:active {
  background: #D4C3AF;
}

.filter-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 14px;
}

.filter-label {
  flex-shrink: 0;
  width: 50px;
  padding-top: 7px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.chip-scroll {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.chip {
  appearance: none;
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.79rem;
  font-weight: 600;
  min-height: 34px;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chip.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

.chip:active {
  transform: scale(0.97);
}

.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px 2px;
  margin-top: 4px;
  border-top: 1px dashed var(--border);
}

.results-count {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.reset-inline-btn {
  appearance: none;
  border: none;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

/* Main content & Cards */
.main-content {
  flex: 1;
  padding: 12px 14px 28px;
}

.hours-notice {
  margin: 0 0 12px;
  padding: 8px 11px;
  background: #F4EDE3;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.spots-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.spot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Meta tags row */
.spot-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  line-height: 1.2;
}

.badge-distance {
  background: var(--jade-soft);
  color: var(--jade);
}

.badge-category {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.badge-time {
  background: #F3ECE3;
  color: var(--text-secondary);
  font-weight: 600;
}

.badge-pick {
  background: #FFF1CC;
  color: #8A4D0D;
  border: 1px solid #F0CE78;
}

/* Internal Tag Pills */
.spot-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: -4px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-warm);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  line-height: 1.3;
}

/* Spot Titles */
.spot-heading {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.spot-name-local {
  margin: 0;
  font-family: var(--font-tc);
  font-size: 1.28rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text);
  letter-spacing: 0.01em;
}

.spot-name-translated {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Hamuya Owner Note */
.owner-note {
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  border-radius: 12px;
  padding: 11px 13px;
}

.owner-note-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--amber-text);
  margin-bottom: 4px;
}

.owner-note-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #3A2714;
}

/* Point and Order Card */
.point-order-box {
  background: var(--surface-point);
  border: 2px dashed #DFB29F;
  border-radius: 13px;
  padding: 12px 13px;
}

.point-order-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.point-order-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.point-expand-btn {
  appearance: none;
  border: 1px solid #E5C2B4;
  background: var(--surface);
  color: var(--primary-dark);
  font-size: 0.73rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  min-height: 28px;
}

.point-expand-btn:active {
  background: var(--primary-soft);
}

.point-order-zh {
  margin: 0;
  font-family: var(--font-tc);
  font-size: 1.32rem;
  font-weight: 800;
  line-height: 1.45;
  color: #1A1410;
  word-break: break-word;
}

.point-order-translation {
  margin: 6px 0 0;
  padding-top: 6px;
  border-top: 1px solid #EFE4D6;
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Action Buttons */
.spot-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-height: 46px;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.btn:active {
  transform: scale(0.985);
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(200, 75, 49, 0.24);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface);
  color: var(--jade);
  border: 1.5px solid #BBD8CC;
}

.btn-secondary:hover {
  background: var(--jade-soft);
}

.btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Empty & Error States */
.state-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 32px 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.state-icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.state-title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 800;
}

.state-desc {
  margin: 0 0 18px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* Footer */
.app-footer {
  padding: 8px 16px 24px;
  text-align: center;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.app-footer p {
  margin: 0;
}

/* Full-screen Point & Order Modal */
.point-modal[hidden] {
  display: none;
}

.point-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.point-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(25, 18, 14, 0.62);
}

.point-modal-sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  min-height: 62dvh;
  max-height: 92dvh;
  background: #FFFFFF;
  border-radius: 24px 24px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.25);
  overflow-y: auto;
}

.point-modal-head {
  text-align: center;
}

.point-modal-badge {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  margin-bottom: 6px;
}

.point-modal-shop {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.point-modal-body {
  text-align: center;
  padding: 12px 6px;
}

.point-modal-zh {
  margin: 0;
  font-family: var(--font-tc);
  font-size: clamp(1.9rem, 7.5vw, 2.5rem);
  font-weight: 900;
  line-height: 1.42;
  color: #120E0B;
  word-break: break-word;
}

.point-modal-sub {
  margin: 16px 0 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.point-modal-close {
  min-height: 50px;
  font-size: 1rem;
}

@media (min-width: 540px) {
  .app-shell {
    margin-top: 16px;
    margin-bottom: 16px;
    min-height: calc(100dvh - 32px);
    border: 1px solid var(--border);
    border-radius: 22px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
  }

  .point-modal {
    align-items: center;
    padding: 16px;
  }

  .point-modal-sheet {
    min-height: auto;
    border-radius: 22px;
  }
}
