/* ══════════════════════════════
   base.css — 共用样式
   Living Japanese v3.0
══════════════════════════════ */

/* ── Design Tokens ── */
:root {
  --bg:           #F2F2F7;
  --surface:      #FFFFFF;
  --glass:        rgba(242,242,247,0.88);
  --glass-dark:   rgba(22,22,24,0.94);
  --glass-black:  rgba(28,28,30,0.80);
  --t1:           #1C1C1E;
  --t2:           #3A3A3C;
  --t3:           #636366;
  --t4:           #8E8E93;
  --line:         rgba(60,60,67,0.13);
  --red:          #FF3B30;
  --red-bg:       rgba(255,59,48,0.10);
  --blue:         #007AFF;
  --blue-bg:      rgba(0,122,255,0.10);
  --green:        #34C759;
  --green-bg:     rgba(52,199,89,0.10);
  --yellow:       #FFD60A;
  --r-sm:         10px;
  --r-md:         14px;
  --r-lg:         20px;
  --r-xl:         28px;
  --tab-h:        56px;
  --ctrl-h:       82px;
}

/* ── Reset ── */
*,*::before,*::after {
  box-sizing: border-box;
  margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
}
html { background: #E5E5EA; }

body {
  font-family: -apple-system, "SF Pro Text", "Hiragino Sans",
               "Noto Sans JP", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--t1);
  -webkit-text-size-adjust: 100%;
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
}
@media(min-width:430px){
  body {
    box-shadow: 0 0 0 .5px rgba(0,0,0,.08),
                0 8px 48px rgba(0,0,0,.14);
  }
}

/* ── Panels ── */
.panel { display: none; }
.panel.on { display: block; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center; justify-content: center; gap: 4px;
  font-size: 13px; font-weight: 600;
  border-radius: var(--r-sm);
  border: none; padding: 7px 13px; min-height: 36px;
  background: rgba(118,118,128,0.13);
  color: var(--t2);
  cursor: pointer; white-space: nowrap; letter-spacing: -.1px;
  transition: background .15s, transform .1s cubic-bezier(.34,1.56,.64,1), color .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.btn:active { transform: scale(.91); box-shadow: none; }
.btn.dk   { background: var(--t1); color: #fff; }
.btn.dk:active { background: var(--t2); }
.btn.rd   { background: var(--red-bg); color: var(--red); }
.btn.bl   { background: var(--blue-bg); color: var(--blue); }
.btn.gn   { background: var(--green-bg); color: var(--green); }
.btn.on   { background: var(--t1); color: #fff; }
.btn.sm   { font-size: 12px; padding: 5px 10px; min-height: 28px; border-radius: 9px; }
.btn.stopped { background: var(--red); color: #fff; }

/* Segmented control */
.seg {
  display: inline-flex;
  background: rgba(118,118,128,0.13);
  border-radius: var(--r-sm); padding: 2px; gap: 1px;
}
.seg .btn {
  background: transparent; border-radius: 8px;
  font-size: 12px; padding: 5px 9px; min-height: 28px;
  color: var(--t2);
}
.seg .btn.on {
  background: var(--surface); color: var(--t1);
  box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 1px rgba(0,0,0,.06);
}

/* ── Header ── */
#header {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px; z-index: 300;
  background: var(--glass);
  backdrop-filter: saturate(200%) blur(24px);
  -webkit-backdrop-filter: saturate(200%) blur(24px);
  border-bottom: .5px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.header-bar {
  height: 52px; display: flex;
  align-items: center; padding: 0 14px; gap: 10px;
}
.wordmark {
  font-size: 17px; font-weight: 700; letter-spacing: -.4px;
  color: var(--t1); flex-shrink: 0;
  display: flex; align-items: center; gap: 5px;
}
.wordmark-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red); flex-shrink: 0;
}
.search-wrap { flex: 1; position: relative; }
.search-wrap svg {
  position: absolute; left: 9px; top: 50%;
  transform: translateY(-50%);
  color: var(--t4); pointer-events: none;
}
#searchInput {
  width: 100%; height: 36px; padding: 0 10px 0 32px;
  background: rgba(118,118,128,0.13);
  border: none; border-radius: 12px;
  font-size: 15px; color: var(--t1); outline: none;
  transition: background .15s;
}
#searchInput:focus { background: rgba(118,118,128,0.20); }
#searchInput::placeholder { color: var(--t4); }

/* Scene bar */
#sceneBarWrap { border-bottom: .5px solid var(--line); }
#sceneTagsWrap {
  display: flex; flex-wrap: wrap;
  padding: 7px 14px 5px; gap: 6px;
  max-height: 80px; overflow: hidden;
  transition: max-height .32s cubic-bezier(.4,0,.2,1);
}
#sceneTagsWrap.expanded { max-height: 600px; }
#sceneToggle {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 22px; border: none; background: none;
  cursor: pointer; position: relative;
}
#sceneToggle::before,
#sceneToggle::after {
  content: ''; position: absolute; top: 50%;
  width: calc(50% - 18px); height: .5px;
  background: var(--line);
}
#sceneToggle::before { left: 14px; }
#sceneToggle::after  { right: 14px; }
.stoggle-arrow {
  font-size: 22px; color: var(--t4); line-height: 1;
  z-index: 1; background: var(--bg); padding: 0 6px;
}
.stag {
  flex-shrink: 0; height: 28px; padding: 0 11px;
  border-radius: var(--r-lg); font-size: 12px; font-weight: 600;
  background: var(--surface); color: var(--t4);
  border: .5px solid var(--line);
  cursor: pointer; white-space: nowrap;
  transition: all .18s cubic-bezier(.34,1.56,.64,1);
  display: flex; align-items: center; gap: 4px;
}
.stag:active { transform: scale(.92); }
.stag.on { background: var(--t1); color: #fff; border-color: var(--t1); }
.stag-icon { font-size: 13px; }

/* ── Tab Bar ── */
main { padding-bottom: 76px; }
main.has-ctrl { padding-bottom: 158px; }
#tabBar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px; z-index: 300;
  background: var(--glass);
  backdrop-filter: saturate(200%) blur(24px);
  -webkit-backdrop-filter: saturate(200%) blur(24px);
  border-top: .5px solid var(--line);
  display: flex; align-items: flex-start; padding-top: 10px;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 3px;
  cursor: pointer; border: none; background: none; padding: 0;
  color: var(--t4); font-size: 10px; font-weight: 500;
  letter-spacing: .01em; transition: color .15s; position: relative;
}
.tab.on { color: var(--red); }
.tab-icon {
  width: 28px; height: 28px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .12s; font-size: 18px;
}
.tab.on .tab-icon { background: var(--red-bg); transform: scale(1.10); }
.tab:active .tab-icon { transform: scale(.82); }

/* ── Back to Top ── */
#backTop {
  position: fixed;
  bottom: calc(var(--tab-h) + var(--ctrl-h) + 12px); right: 16px;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--glass-black);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 14px rgba(0,0,0,.22);
  opacity: 0; transform: translateY(8px) scale(.8);
  transition: opacity .2s, transform .2s; z-index: 90;
}
#backTop.on { opacity: 1; transform: translateY(0) scale(1); }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: calc(var(--tab-h) + var(--ctrl-h) + 14px); left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--glass-dark);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  color: #fff; font-size: 13px; font-weight: 600;
  padding: 9px 18px; border-radius: 22px;
  opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none; z-index: 400;
  white-space: nowrap; max-width: 360px;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Placeholder panels ── */
.ph {
  padding: 70px 28px 40px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.ph-icon { font-size: 52px; line-height: 1; }
.ph-title { font-size: 20px; font-weight: 700; letter-spacing: -.2px; }
.ph-desc { font-size: 14px; color: var(--t4); line-height: 1.7; max-width: 260px; }
.ph-badge {
  margin-top: 6px; display: inline-block;
  background: var(--t1); color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 6px 16px; border-radius: 20px; letter-spacing: .04em;
}

/* ── 页面过渡动画 ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInFast {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Loading ── */
#loading {
  text-align: center; padding: 60px 20px;
  color: var(--t4); font-size: 14px;
}