:root {
  --ink: #1e2a25;
  --muted: #69766f;
  --canvas: #e8eee9;
  --surface: #f9fbf8;
  --line: #d4ded6;
  --pine: #183e32;
  --pine-2: #285d49;
  --red: #aa3e35;
  --amber: #b67721;
  --amber-soft: #faeed6;
  --danger-soft: #f7e3e0;
  --shadow: 0 16px 40px rgba(25, 53, 43, 0.12);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(182, 119, 33, 0.34);
  outline-offset: 2px;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  max-width: 560px;
  margin: 0 auto;
  background: var(--surface);
  box-shadow: 0 0 0 1px rgba(24, 62, 50, 0.05), var(--shadow);
  padding: env(safe-area-inset-top) 16px calc(92px + env(safe-area-inset-bottom));
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 0 2px 14px;
  margin-bottom: 18px;
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--pine);
  border-radius: 8px;
}

.brand-mark svg { width: 19px; height: 19px; }
.brand-name { display: block; color: var(--pine); font: 700 20px/1 "Noto Serif SC", serif; }
.brand-kicker { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; letter-spacing: 0.06em; }
.online-state { display: inline-flex; align-items: center; gap: 6px; color: var(--pine-2); font-size: 12px; font-weight: 600; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: #5a967a; box-shadow: 0 0 0 3px rgba(90, 150, 122, 0.15); }

.now-playing {
  background: var(--pine);
  color: white;
  border-radius: 8px;
  padding: 15px 16px;
  min-height: 96px;
  display: flex;
  gap: 14px;
  align-items: center;
  position: relative;
  overflow: hidden;
}
.now-playing::after {
  content: "";
  position: absolute;
  right: -15px;
  bottom: -30px;
  width: 128px;
  height: 128px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  box-shadow: 0 0 0 18px rgba(255,255,255,.05), 0 0 0 36px rgba(255,255,255,.035);
}
.playing-icon { position: relative; z-index: 1; width: 40px; height: 40px; border: 1px solid rgba(255,255,255,.35); border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; }
.playing-icon svg { width: 18px; height: 18px; }
.now-label { position: relative; z-index: 1; opacity: .68; font-size: 11px; letter-spacing: .08em; }
.now-title { position: relative; z-index: 1; margin-top: 5px; font-size: 17px; font-weight: 700; max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-copy { position: relative; z-index: 1; color: rgba(255,255,255,.7); margin-top: 4px; font-size: 12px; }
.stop-button { position: relative; z-index: 2; margin-left: auto; width: 38px; height: 38px; padding: 0; border: 0; background: rgba(255,255,255,.14); color: white; display: grid; place-items: center; border-radius: 8px; }
.stop-button:disabled { opacity: .42; cursor: default; }
.stop-button svg { width: 17px; }

.section-heading { margin: 25px 0 12px; display: flex; justify-content: space-between; align-items: baseline; }
.section-heading h1, .section-heading h2 { margin: 0; color: var(--ink); font-size: 18px; line-height: 1.2; }
.section-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.section-heading .count { color: var(--muted); font-size: 12px; }

.cue-list { display: grid; gap: 10px; }
.cue-card { border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; }
.cue-card.is-disabled { opacity: .54; }
.cue-main { width: 100%; display: flex; align-items: center; gap: 13px; padding: 15px 13px; border: 0; text-align: left; background: white; color: var(--ink); }
.cue-main:active { background: #f3f7f4; }
.cue-play { width: 39px; height: 39px; border-radius: 50%; display: grid; place-items: center; background: var(--amber-soft); color: var(--amber); flex: 0 0 auto; }
.cue-play svg { width: 18px; height: 18px; }
.cue-main.is-playing .cue-play { background: var(--pine); color: #fff; }
.cue-copy { min-width: 0; flex: 1; }
.cue-name { display: block; font-size: 15px; font-weight: 700; }
.cue-text { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cue-meta { flex: 0 0 auto; color: #7e8b84; }
.cue-meta svg { width: 18px; height: 18px; }
.cue-footer { display: flex; flex-wrap: wrap; align-items: center; min-height: 37px; padding: 0 12px 0 15px; border-top: 1px solid #edf1ee; }
.badge { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; }
.badge svg { width: 13px; height: 13px; }
.cue-edit { margin-left: auto; border: 0; padding: 5px; background: transparent; color: var(--pine-2); display: inline-grid; place-items: center; }
.cue-edit svg { width: 17px; height: 17px; }
.cue-bgm-button { order: 3; flex: 1 0 100%; min-height: 39px; margin: 0 -12px 0 -15px; padding: 0 15px; border: 0; border-top: 1px solid #edf1ee; background: #fbfdfb; color: var(--pine-2); display: flex; align-items: center; gap: 8px; text-align: left; font-size: 12px; font-weight: 700; }
.cue-bgm-button svg { width: 16px; height: 16px; }
.cue-bgm-button:disabled { color: #8b9690; cursor: default; }
.bgm-dock { position: fixed; z-index: 5; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(calc(100% - 24px), 528px); min-height: 60px; padding: 8px 10px; display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(25, 53, 43, .16); }
.bgm-dock-icon { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; color: var(--pine); background: #eaf0eb; border-radius: 7px; }
.bgm-dock-icon svg { width: 17px; height: 17px; }
.bgm-dock-copy { min-width: 0; flex: 1; display: grid; gap: 3px; }
.bgm-dock-copy strong, .bgm-dock-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bgm-dock-copy strong { font-size: 12px; }
.bgm-dock-copy span { color: var(--muted); font-size: 10px; }
.bgm-duck-control { width: 106px; flex: 0 0 auto; display: grid; gap: 2px; color: var(--muted); font-size: 10px; text-align: right; }
.bgm-duck-control input { width: 100%; height: 15px; margin: 0; accent-color: var(--pine-2); }

.empty-state { text-align: center; padding: 46px 20px; border: 1px dashed #b9c9bd; border-radius: 8px; color: var(--muted); }
.empty-state svg { width: 28px; height: 28px; color: var(--pine-2); margin-bottom: 8px; }
.empty-state p { margin: 0 0 14px; font-size: 13px; }

.wide-action { width: 100%; min-height: 50px; border: 1px dashed #9bb1a2; border-radius: 8px; color: var(--pine); background: transparent; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; margin-top: 12px; }
.wide-action svg { width: 18px; height: 18px; }

.bottom-nav { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 560px); min-height: calc(66px + env(safe-area-inset-bottom)); padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, 1fr); background: rgba(249, 251, 248, .96); border-top: 1px solid var(--line); backdrop-filter: blur(12px); }
.nav-button { border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; min-height: 48px; }
.nav-button svg { width: 19px; height: 19px; }
.nav-button.is-active { color: var(--pine); font-weight: 700; }

.page-title { margin: 6px 0 18px; display: flex; align-items: center; justify-content: space-between; }
.page-title h1 { margin: 0; font: 700 24px/1.1 "Noto Serif SC", serif; color: var(--pine); }
.page-title p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.icon-button { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; border: 1px solid var(--line); background: #fff; color: var(--pine); border-radius: 8px; }
.icon-button svg { width: 17px; height: 17px; }

.settings-list { display: grid; gap: 10px; }
.config-section { margin-top: 14px; padding: 15px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.config-section + .config-section { margin-top: 12px; }
.config-section-head { display: flex; gap: 10px; align-items: flex-start; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.config-section-head > svg { width: 21px; height: 21px; margin-top: 1px; color: var(--pine-2); flex: 0 0 auto; }
.config-section-head h2 { margin: 0; color: var(--pine); font-size: 15px; }
.config-section-head p { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.credentials-collapsible { padding: 0; overflow: hidden; }
.credentials-collapsible details { margin: 0; }
.credentials-summary { padding: 15px; border: 0; cursor: pointer; list-style: none; }
.credentials-summary::-webkit-details-marker { display: none; }
.credentials-summary::marker { content: ''; }
.credentials-summary-action { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; color: var(--pine-2); font-size: 11px; font-weight: 700; white-space: nowrap; }
.credentials-summary-action svg { width: 16px; height: 16px; transition: transform .18s ease; }
.credentials-collapsible details[open] .credentials-summary { border-bottom: 1px solid var(--line); }
.credentials-collapsible details[open] .credentials-summary-action svg { transform: rotate(180deg); }
.credentials-collapsible .form-grid { padding: 15px; }
.setting-row { display: flex; align-items: center; gap: 13px; padding: 15px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.setting-row svg { width: 20px; height: 20px; color: var(--pine-2); flex: 0 0 auto; }
.setting-row strong { display: block; font-size: 14px; }
.setting-row span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.setting-row > button { margin-left: auto; border: 0; background: transparent; color: var(--pine-2); padding: 5px; }
.setting-row > button svg { color: inherit; width: 17px; height: 17px; }
.notice { margin-top: 16px; padding: 13px; background: #f2f6f2; border-left: 3px solid #7a9d86; color: #52655a; font-size: 12px; line-height: 1.65; }

.modal-backdrop { position: fixed; inset: 0; z-index: 10; background: rgba(21, 39, 31, .48); display: flex; align-items: flex-end; justify-content: center; }
.modal { width: min(100%, 560px); max-height: min(86vh, 720px); overflow-y: auto; background: #fbfdfb; border-radius: 12px 12px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); }
.modal-handle { width: 40px; height: 4px; border-radius: 4px; background: #c7d2ca; margin: 0 auto 18px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-header h2 { margin: 0; color: var(--pine); font: 700 21px/1.2 "Noto Serif SC", serif; }
.modal-close { padding: 5px; border: 0; background: transparent; color: var(--muted); }
.modal-close svg { width: 20px; height: 20px; }

.form-grid { display: grid; gap: 15px; margin-top: 20px; }
.field { display: grid; gap: 7px; }
.field label, .field-label { color: #405348; font-size: 12px; font-weight: 700; }
.field input, .field textarea, .field select { width: 100%; min-height: 43px; border: 1px solid #cbd7ce; border-radius: 6px; padding: 10px 11px; background: white; color: var(--ink); }
.field textarea { resize: vertical; min-height: 98px; line-height: 1.55; }
.field input[type="range"] { min-height: 0; padding: 0; accent-color: var(--pine-2); }
.range-line { display: flex; align-items: center; gap: 11px; }
.range-value { min-width: 44px; text-align: right; color: var(--muted); font-size: 12px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice { display: flex; align-items: center; gap: 8px; padding: 10px; border: 1px solid #cbd7ce; border-radius: 6px; background: #fff; font-size: 12px; }
.choice input { width: 16px; height: 16px; margin: 0; accent-color: var(--pine-2); }
.subtle-help { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.form-divider { height: 1px; background: var(--line); margin: 3px 0; }
.voice-profile-row { position: relative; display: grid; gap: 11px; padding: 13px 48px 13px 13px; border: 1px solid var(--line); border-radius: 7px; background: #f7faf7; margin-bottom: 10px; }
.voice-remove { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; color: var(--red); background: #fff; }
.modal-actions { position: sticky; z-index: 1; bottom: -20px; display: flex; gap: 10px; margin-top: 22px; padding: 12px 0 3px; background: #fbfdfb; }
.button { border: 0; border-radius: 7px; min-height: 45px; padding: 0 15px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.button svg { width: 17px; height: 17px; }
.button.primary { background: var(--pine); color: #fff; flex: 1; }
.button.secondary { background: #eaf0eb; color: var(--pine); }
.button.danger { background: var(--danger-soft); color: var(--red); }
.button:disabled { opacity: .55; cursor: default; }
.hidden { display: none !important; }
.toast-region { position: fixed; z-index: 30; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(92vw, 420px); pointer-events: none; }
.toast { padding: 11px 13px; border-radius: 7px; box-shadow: var(--shadow); background: #23382f; color: white; font-size: 13px; text-align: center; }
.toast.error { background: #8e352e; }

@media (min-width: 561px) {
  body { padding: 22px; }
  .app-shell { min-height: calc(100vh - 44px); border-radius: 12px; }
  .bottom-nav { bottom: 22px; border-radius: 0 0 12px 12px; }
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { border-radius: 12px; max-height: 80vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
