/* MyStock — mobile-first UI inspired by yuyu_etf_mobile_site (warm lab theme).
   Taiwan convention: red = up, green = down — use .up-red / .down-green only. */

:root {
  --bg-outer: #eadfd4;
  --bg-phone-top: #fffaf5;
  --bg-phone-bottom: #f7f0e8;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #fffaf5;
  --text: #4d3d34;
  --muted: #9b7e68;
  --muted2: #b5947d;
  --accent: #c9a98f;
  --accent-hot: #e45f70;
  --accent-secondary: #8b6f5d;
  --rose: #e78e9b;
  --border-soft: #f0e2d8;
  --border-card: rgba(255, 255, 255, 0.78);
  --shadow-card: 0 14px 35px rgba(120, 90, 60, 0.1);
  --shadow-soft: 0 10px 25px rgba(120, 90, 60, 0.09);
  --up-red: #c53030;
  --down-green: #2f855a;
  --link: #b7791f;
  --tabbar-h: 88px;
  --radius: 24px;
  --radius-sm: 18px;
  --phone-max: 430px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans TC", "PingFang TC",
    "Microsoft JhengHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  /* pan-x pan-y：盡量保留捲動、減少雙指縮放；manipulation 仍允許 pinch-zoom */
  touch-action: pan-x pan-y;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* iOS：表單字級小於 16px 時聚焦會強制放大；觸控裝置一律至少 16px */
@media (pointer: coarse) {
  input[type='text'],
  input[type='search'],
  input[type='number'],
  input[type='email'],
  input[type='tel'],
  input[type='url'],
  input[type='password'],
  textarea,
  select {
    font-size: max(16px, 1em);
  }
}

body.yuyu-theme {
  background: var(--bg-outer);
  min-height: 100vh;
  padding-bottom: 0;
}

body.yuyu-theme .phone {
  max-width: var(--phone-max);
  min-height: 100vh;
  margin: 0 auto;
  position: relative;
  overflow-x: hidden;
  background: linear-gradient(180deg, var(--bg-phone-top) 0%, var(--bg-phone-bottom) 100%);
  box-shadow: 0 0 50px rgba(80, 55, 40, 0.12);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px 10px;
  background: rgba(255, 250, 245, 0.92);
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(14px);
}

.topbar-brand .logo {
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.3px;
  color: var(--text);
}

.topbar-brand .logo span {
  color: var(--rose);
}

.subtitle {
  font-size: 12px;
  color: var(--muted2);
  margin-top: 4px;
  font-weight: 500;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 6px 20px rgba(120, 90, 60, 0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent-secondary);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.icon-btn:active {
  opacity: 0.75;
  transform: scale(0.96);
}

.icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ---------- Main content ---------- */
#content {
  padding: 8px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0));
}

.tab-panel {
  display: none;
  animation: panelFade 0.22s ease;
}

.tab-panel.active {
  display: block;
}

@keyframes panelFade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Hero (ETF tab) ---------- */
.hero {
  position: relative;
  min-height: 168px;
  border-radius: 30px;
  padding: 18px 130px 18px 18px;
  margin-bottom: 4px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.hero-text .eyebrow {
  color: var(--rose) !important;
  font-weight: 800;
  font-size: 12px;
  margin: 0 0 6px;
  letter-spacing: 0.02em;
}

.hero-text h1 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.18;
  font-weight: 900;
  color: var(--text);
}

.hero-text p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}

.hero .glow {
  position: absolute;
  right: 40px;
  top: 22px;
  width: 130px;
  height: 130px;
  background: #ffdce4;
  border-radius: 50%;
  filter: blur(42px);
  opacity: 0.88;
  pointer-events: none;
}

.hero .cat {
  position: absolute;
  right: 12px;
  bottom: 4px;
  width: 118px;
  height: 118px;
  object-fit: cover;
  border-radius: 24px;
  filter: drop-shadow(0 12px 12px rgba(80, 55, 40, 0.18));
}

.hero .float {
  position: absolute;
  font-size: 22px;
  opacity: 0.4;
  pointer-events: none;
}

.hero .heart-float {
  top: 16px;
  right: 108px;
  color: #ef8d9a;
}

.hero .paw-float {
  left: 16px;
  bottom: 14px;
}

/* ---------- Search ---------- */
.search {
  margin: 14px 0 12px;
  height: 50px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.82);
  padding: 0 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(255, 255, 255, 0.9);
}

.search svg {
  width: 20px;
  height: 20px;
  fill: #9a7d68;
  flex-shrink: 0;
}

.search input {
  border: 0;
  outline: 0;
  background: transparent;
  width: 100%;
  font-size: 16px;
  color: var(--text);
}

.search input::placeholder {
  color: var(--muted2);
}

/* ---------- Section heads ---------- */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0 10px;
}

.section-head h2 {
  font-size: 18px;
  margin: 0;
  font-weight: 900;
  color: var(--text);
}

.section-head span {
  font-size: 12px;
  color: var(--muted2);
}

.section-title {
  margin: 16px 0 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* Yuyu-style segmented control (比對 / 排行 / 加減碼) */
.tab-lead {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.tab-back {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: 14px;
  margin: 0 0 12px;
  padding: 4px 0;
  cursor: pointer;
  text-align: left;
}

.tab-back:active {
  opacity: 0.65;
}

.switch,
.period {
  display: flex;
  gap: 8px;
  margin: 4px 0 14px;
  flex-wrap: wrap;
}

.switch button,
.period button {
  border: 0;
  border-radius: 999px;
  background: #f2e4d8;
  color: #8b6f5d;
  padding: 9px 14px;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.switch button.active,
.period button.active {
  background: var(--accent);
  color: #fff;
}

.switch button:disabled,
.period button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.switch button.teaser-btn:not(.active) {
  opacity: 0.85;
}

/* ETF 交叉比對：規格表 + 表單 */
.etf-compare-summary {
  padding: 14px 16px;
}

.etf-compare-pair-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}

.etf-compare-pair-head > div:first-child {
  text-align: left;
}

.etf-compare-pair-head > div:last-child {
  text-align: right;
}

.etf-compare-vs {
  font-weight: 900;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
}

.etf-compare-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -2px;
}

.etf-compare-table {
  width: 100%;
  min-width: 300px;
  border-collapse: collapse;
  font-size: 13px;
}

.etf-compare-table th,
.etf-compare-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}

.etf-compare-table thead th {
  text-align: left;
  color: var(--muted);
  font-weight: 800;
  background: rgba(255, 255, 255, 0.72);
}

.etf-compare-table thead th:nth-child(2),
.etf-compare-table thead th:nth-child(3),
.etf-compare-val {
  text-align: right;
}

.etf-compare-label {
  min-width: 104px;
  font-weight: 700;
  color: var(--text);
}

.etf-cross-form {
  padding: 16px;
}

.etf-cross-form label {
  display: block;
  font-size: 12px;
  color: #8a6d59;
  font-weight: 800;
  margin-top: 10px;
}

.etf-cross-form label:first-of-type {
  margin-top: 0;
}

.etf-cross-form input[type='text'],
.etf-cross-form input[type='number'] {
  width: 100%;
  height: 44px;
  border-radius: 14px;
  border: 1px solid #ead8cc;
  background: #fff;
  margin-top: 4px;
  padding: 0 12px;
  font-size: 16px;
  outline: none;
  color: var(--text);
}

.etf-cross-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 169, 143, 0.25);
}

.etf-cross-form .btn.primary {
  margin-top: 16px;
}

/* 公司大卡（比對頁、可再用於 modal） */
.company-card {
  padding: 16px 15px;
}

.company-top {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  align-items: flex-start;
}

.logo-dot {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(145deg, #e45555, #f08585);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 17px;
  flex-shrink: 0;
}

.company-name {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  color: var(--text);
  line-height: 1.25;
}

.company-name .muted {
  font-weight: 700;
  font-size: 13px;
}

.company-desc {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
}

.company-perf {
  font-weight: 900;
  font-size: 14px;
  white-space: nowrap;
  align-self: center;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chips span {
  background: #f6ece4;
  color: #7a5c4e;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.btn-text {
  margin-top: 12px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.btn-text:active {
  opacity: 0.65;
}

.rank-row,
.compare-row {
  cursor: default;
}

.foot-note {
  text-align: center;
  padding: 14px !important;
}

.foot-note p {
  margin: 0;
}

.modal-hero {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
}

.modal-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 900;
}

.holdings-table-wrap {
  border-radius: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.55);
}

.etf-card .holdings-table-wrap table th,
.etf-card .holdings-table-wrap table td:first-child {
  padding-left: 10px;
}

.etf-card .holdings-table-wrap table th.col-num,
.etf-card .holdings-table-wrap table td.col-num {
  text-align: right;
  white-space: nowrap;
  font-size: 12px;
  padding-left: 4px;
  padding-right: 8px;
}

.etf-card .holdings-table-wrap table thead th {
  font-size: 11px;
  line-height: 1.2;
  vertical-align: bottom;
}

.etf-card .holdings-table-wrap table .holdings-th-scale-delta .th-sub,
.etf-card .holdings-table-wrap table .holdings-th-weight-delta .th-sub {
  font-weight: 600;
  opacity: 0.85;
}

.etf-card .holdings-name-code-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1.25;
  min-width: 0;
}

.etf-card .holdings-name-code-stack .holdings-code-line {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.etf-card .holdings-name-code-stack .holdings-name-line {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
}

.etf-card .holdings-pos-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid currentColor;
  opacity: 0.95;
}

.etf-card .holdings-scale-delta-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  line-height: 1.25;
}

.etf-card .holdings-scale-delta-stack .holdings-delta-line {
  font-size: 12px;
}

.etf-card .holdings-weight-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  line-height: 1.25;
}

.etf-card .holdings-weight-stack .holdings-weight-delta-line {
  font-size: 12px;
}

.etf-card .holdings-delta-note {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.45;
}

.universe-meta {
  margin: -4px 0 10px;
  padding: 0 2px;
  font-size: 12px;
  line-height: 1.45;
}

.primary:disabled {
  opacity: 0.55;
  cursor: default;
  box-shadow: none;
}

/* ---------- Cards & lists ---------- */
.card {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  padding: 14px 15px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
}

.card.list {
  padding: 4px 0;
}

.card.list .etf-card {
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 0;
}

.card.list .etf-card:last-child {
  border-bottom: 0;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.card-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

/* Yuyu-style three-column list row */
.list-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
}

.list-row:last-child {
  border-bottom: 0;
}

.etf-list-row {
  min-height: 56px;
}

.etf-code-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, #8fb4e9, #77d0bf);
}

.list-row .code-label {
  font-weight: 900;
  font-size: 15px;
  color: var(--text);
}

.list-row .name-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.list-row .ranknum {
  font-weight: 900;
  color: #d58a60;
  text-align: center;
  font-size: 14px;
}

/* Flex row for key-value lines (加減碼、計算機) — was .row */
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
}

.stat-row:last-child {
  border-bottom: 0;
}

.up-red { color: var(--up-red); font-weight: 800; }
.down-green { color: var(--down-green); font-weight: 800; }
.flat { color: var(--muted); }

/* Pill badges (ETF tags, intraday, etc.) */
.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  border-radius: 999px;
  padding: 0 8px;
  margin: 2px 4px 2px 0;
  font-size: 11px;
  color: #6b5142;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.65);
  font-weight: 600;
}

.badge.up {
  color: #9b2c2c;
  border-color: #f5c6c6;
  background: #fff0f0;
}

.badge.down {
  color: #276749;
  border-color: #c6f6d5;
  background: #f0fff4;
}

.badge.intraday {
  color: #8a5a00;
  border-color: #ffd97a;
  background: #fff7e0;
}

/* 首頁：大盤 / 台指期參考 / NASDAQ */
.market-brief-bar {
  margin-top: 4px;
  margin-bottom: 6px;
  padding: 12px 14px 10px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
}

.market-brief-top {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.market-brief-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 360px) {
  .market-brief-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
}

.market-brief-item {
  min-width: 0;
  padding: 8px 6px;
  border-radius: 12px;
  background: rgba(255, 252, 248, 0.65);
  border: 1px solid rgba(240, 226, 216, 0.9);
}

.market-brief-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted2);
  margin-bottom: 4px;
  line-height: 1.25;
}

.market-brief-value {
  font-size: 16px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.market-brief-change {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 800;
}

.market-brief-asof {
  font-size: 10px;
  margin-top: 4px;
}

.market-brief-disclaimer {
  font-size: 11px;
  line-height: 1.45;
  margin: 10px 0 0;
}

.market-brief-foot {
  font-size: 10px;
  margin: 6px 0 0;
}

.market-brief-fallback {
  margin: 0;
  font-size: 12px;
}

/* 首頁：全體 ETF 加碼前五名（文字列表） */
.home-top-inc-card {
  margin-top: 8px;
  margin-bottom: 4px;
  padding: 14px 14px 16px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
}

.home-top-inc-head {
  margin-top: 0;
  margin-bottom: 8px;
}

.home-top-inc-head h2 {
  font-size: 16px;
  line-height: 1.35;
  font-weight: 900;
}

.home-top-inc-disclaimer {
  font-size: 12px;
  line-height: 1.5;
  margin: 0 0 12px;
}

.home-top-inc-list {
  font-size: 13px;
  line-height: 1.45;
}

.home-top-inc-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}

.home-top-inc-row:last-child {
  border-bottom: 0;
  padding-bottom: 2px;
}

.home-top-inc-line1 {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.home-top-inc-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  color: #6b5142;
  background: rgba(201, 169, 143, 0.25);
}

.home-top-inc-code {
  font-weight: 900;
  color: var(--text);
}

.home-top-inc-name {
  color: var(--text);
  font-weight: 600;
}

.home-top-inc-line2 {
  font-size: 12px;
  padding-left: 28px;
}

.home-top-inc-amt {
  color: var(--text);
  font-weight: 700;
}

.home-top-inc-empty {
  margin: 0;
  font-size: 12px;
}

/* Shortcuts grid */
.grid-icons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 6px;
}

.grid-icons button {
  border: 0;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.74);
  padding: 12px 6px;
  font-size: 12px;
  color: #6b5142;
  box-shadow: 0 8px 22px rgba(120, 90, 60, 0.08);
  cursor: pointer;
  font-weight: 700;
}

.grid-icons button:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.round-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px;
  font-size: 17px;
}

.pink { background: #f8dce2; }
.blue { background: #dceafa; }
.green { background: #dceee4; }
.peach { background: #ffe3cc; }
.beige { background: #eee0d0; }

/* ETF row inside list */
.etf-card {
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  box-shadow: none;
  margin-bottom: 0;
}

.etf-row-tail {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

.etf-five-day {
  font-size: 13px;
  text-align: right;
  line-height: 1.25;
}

.etf-premium {
  font-size: 12px;
  line-height: 1.35;
  margin-top: 2px;
  color: var(--text-muted, #6b6560);
}

.etf-expand-btn {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: #c4a990;
  font-size: 18px;
  line-height: 1;
  padding: 8px 6px;
  margin: -8px -4px -8px 0;
  cursor: pointer;
  border-radius: 10px;
  transition: transform 0.2s ease, color 0.15s ease, background 0.15s ease;
}

.etf-expand-btn:active {
  background: rgba(196, 169, 144, 0.15);
}

.etf-expand-btn[aria-expanded="true"] {
  transform: rotate(180deg);
  color: #9a7b62;
}

.etf-card .holdings-slot {
  margin: 0;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border-soft);
  background: rgba(255, 252, 248, 0.85);
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border-soft);
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.link {
  color: var(--link);
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
}

.link:active {
  opacity: 0.65;
}

/* Buttons */
.btn {
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  padding: 12px 16px;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(120, 90, 60, 0.14);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.9);
  color: var(--accent-secondary);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-soft);
}

.btn:active {
  opacity: 0.85;
  transform: scale(0.99);
}

.primary {
  width: 100%;
  height: 50px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 10px 25px rgba(120, 90, 60, 0.14);
  cursor: pointer;
}

/* Calculator — yuyu skin */
.calc-hero {
  display: flex;
  gap: 14px;
  align-items: center;
  background: #fff5f2;
  border-radius: 26px;
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border-soft);
}

.calc-hero img {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  object-fit: cover;
  flex-shrink: 0;
}

.calc-hero h2 {
  margin: 0 0 4px;
  font-size: 21px;
  font-weight: 900;
}

.calc-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.calculator label,
.form-group label {
  font-size: 12px;
  color: #8a6d59;
  font-weight: 800;
}

.calculator input[type='number'],
.form-group input,
.form-group select {
  width: 100%;
  height: 48px;
  border-radius: 14px;
  border: 1px solid #ead8cc;
  background: #fff;
  margin: 6px 0 12px;
  padding: 0 12px;
  font-size: 16px;
  outline: none;
  color: var(--text);
}

.calculator .calc-checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 12px;
  font-size: 13px;
  font-weight: 800;
  color: #8a6d59;
  cursor: pointer;
}

.calculator .calc-checkbox-row input[type='checkbox'] {
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.form-group input:focus,
.form-group select:focus,
.calculator input[type='number']:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 169, 143, 0.25);
}

.calc-result-wrap {
  margin-top: 10px;
}

.calc-breakdown {
  background: rgba(255, 255, 255, 0.65);
  border-radius: 16px;
  padding: 8px 12px;
  border: 1px solid var(--border-soft);
  margin-bottom: 10px;
}

.calc-total-inner {
  background: #fff0f2;
  border: 1px solid #f0b5be;
  border-radius: 20px;
  padding: 16px;
  text-align: center;
}

.calc-total-inner span {
  display: block;
  color: #c0565c;
  font-size: 12px;
  font-weight: 900;
}

.calc-total-inner strong {
  display: block;
  color: var(--up-red);
  font-size: 28px;
  margin-top: 4px;
  font-weight: 900;
}

.btn.primary {
  width: 100%;
  margin-top: 4px;
}

.quick-btns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.quick-btns button {
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: #f2e4d8;
  color: #775f50;
  font-weight: 900;
  font-size: 13px;
  cursor: pointer;
}

/* Bottom nav */
.tabbar.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--phone-max);
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0));
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-soft);
  box-shadow: 0 -4px 24px rgba(80, 55, 40, 0.06);
}

.tab-btn.nav {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 12px;
  padding: 4px 2px;
  font-weight: 600;
}

.tab-btn.nav .tab-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tab-btn.nav.active {
  color: var(--accent-hot);
}

.tab-ico {
  font-size: 17px;
  line-height: 1;
}

/* Modal & toast */
.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(60, 40, 30, 0.35);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: var(--phone-max);
  max-height: 86vh;
  overflow-y: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--bg-phone-top);
  padding: 18px 16px calc(22px + env(safe-area-inset-bottom, 0));
  border: 1px solid var(--border-soft);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: #f2e4d8;
  color: var(--accent-secondary);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 12px);
  transform: translateX(-50%);
  max-width: min(90vw, var(--phone-max));
  z-index: 200;
  border-radius: 999px;
  background: rgba(60, 45, 38, 0.94);
  color: #fff;
  font-size: 13px;
  padding: 10px 16px;
  font-weight: 600;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 14px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (min-width: 760px) {
  body.yuyu-theme .phone {
    margin-top: 12px;
    margin-bottom: 12px;
    min-height: calc(100vh - 24px);
    border-radius: 24px;
    border: 1px solid rgba(120, 90, 60, 0.12);
  }

  .tabbar.bottom-nav {
    border-radius: 0 0 24px 24px;
  }
}
