:root {
  --bg: #131722;
  --surface: #1e222d;
  --surface-2: #2a2e39;
  --surface-glass: rgba(24, 28, 39, 0.88);
  --border: #2a2e39;
  --text: #d1d4dc;
  --text-strong: #f2f4f8;
  --text-muted: #787b86;
  --accent: #2962ff;
  --accent-soft: rgba(41, 98, 255, 0.22);
  --up: #089981;
  --down: #f23645;
  --up-bg: rgba(8, 153, 129, 0.16);
  --down-bg: rgba(242, 54, 69, 0.16);
  --warn: #f59e0b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --surface: #f8f9fd;
  --surface-2: #e9ecf4;
  --surface-glass: rgba(255, 255, 255, 0.90);
  --border: #e0e3eb;
  --text: #131722;
  --text-strong: #0b0e14;
  --text-muted: #6a6d78;
  --accent: #2962ff;
  --accent-soft: rgba(41, 98, 255, 0.12);
  --up: #089981;
  --down: #f23645;
  --up-bg: rgba(8, 153, 129, 0.12);
  --down-bg: rgba(242, 54, 69, 0.12);
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  touch-action: manipulation;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

.hidden {
  display: none !important;
}

/* Auth Screen */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 20px;
  box-shadow: var(--shadow);
}

.auth-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-strong);
  margin-bottom: 8px;
}

.auth-title img {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.auth-desc {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.auth-input {
  width: 100%;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-strong);
  font-size: 16px;
  padding: 0 14px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.auth-input:focus {
  border-color: var(--accent);
}

.btn-primary {
  width: 100%;
  height: 44px;
  margin-top: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.auth-error {
  margin-top: 10px;
  color: var(--down);
  font-size: 13px;
  min-height: 18px;
}

/* App Shell */
.app-shell {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  background: var(--bg);
}

.main-area {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* Chart Stage */
.chart-stage {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--bg);
}

#chartCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* TradingView Mobile Top-Left Header */
.tv-legend {
  position: absolute;
  top: 6px;
  left: 10px;
  right: 68px;
  z-index: 6;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.legend-head-row {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  max-width: 100%;
}

.legend-symbol-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 1px 0;
  border: none;
  background: transparent;
  color: var(--text-strong);
  cursor: pointer;
  white-space: nowrap;
  max-width: 100%;
}

.legend-avatar {
  width: 21px;
  height: 21px;
  border-radius: 999px;
  background: #2962ff;
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.3px;
}

.legend-sym {
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.1px;
  color: var(--text-strong);
}

.legend-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  border: none;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--up);
}

.legend-star-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.legend-star-btn.active {
  color: #f5b91a;
}

.legend-price-line {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  margin-bottom: 2px;
}

.legend-price-line.ohlc-detail {
  font-size: 11px;
}

.ohlc-up { color: var(--up); }
.ohlc-down { color: var(--down); }

.color-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  flex-shrink: 0;
}

/* TradingView Mobile Inline Legend Stack (Compare + Studies) */
.tv-leg-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  max-height: 48vh;
  overflow-y: auto;
  scrollbar-width: none;
  pointer-events: none;
}

.tv-leg-stack::-webkit-scrollbar {
  display: none;
}

.tv-leg-row {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  min-height: 23px;
  padding: 1px 6px 1px 1px;
  border-radius: 7px;
  border: 1.5px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.tv-leg-row.active {
  background: var(--bg);
  border-color: #2962ff;
  padding: 3px 6px 3px 5px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.14);
}

.tv-leg-row.is-hidden .tv-leg-name {
  color: var(--text-muted);
  opacity: 0.62;
}

.tv-leg-badge {
  width: 19px;
  height: 19px;
  border-radius: 999px;
  font-size: 8px;
  font-weight: 800;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.4px;
}

.tv-leg-name {
  color: var(--text-strong);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.tv-leg-val {
  font-weight: 500;
  white-space: nowrap;
}

.tv-leg-status {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.tv-leg-eye-inline {
  border: none;
  background: transparent;
  color: var(--text-strong);
  padding: 1px 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.85;
}

.tv-leg-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 4px;
}

.tv-leg-act-btn {
  width: 30px;
  height: 24px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.tv-leg-act-btn:active {
  background: var(--surface-2);
}

.tv-leg-act-btn.danger {
  color: var(--down);
}

.tv-leg-collapse {
  pointer-events: auto;
  align-self: flex-start;
  width: auto;
  margin-top: 3px;
  height: 22px;
  min-width: 28px;
  padding: 0 7px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-glass);
  color: var(--text-strong);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

/* Series Settings Color Swatch Grid */
.color-palette-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  padding: 4px 0 8px;
}

.palette-swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 38px;
  margin: 0 auto;
  border-radius: 999px;
  border: 2.5px solid transparent;
  cursor: pointer;
}

.palette-swatch.active {
  border-color: var(--text-strong);
  box-shadow: 0 0 0 2px var(--accent);
}

/* Floating Banners (Draw prompt / Replay pick) */
.floating-banner {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-glass);
  border: 1px solid var(--accent);
  color: var(--text-strong);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  max-width: calc(100% - 16px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.floating-banner.replay-banner {
  border-color: var(--warn);
}

.banner-chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-strong);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.banner-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.banner-chip.danger {
  color: var(--down);
}

/* Selected Drawing Floating Edit Bar */
.draw-edit-bar {
  position: absolute;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 12px;
  background: var(--surface-glass);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  max-width: calc(100% - 16px);
  overflow-x: auto;
}

.draw-swatches {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-right: 4px;
  border-right: 1px solid var(--border);
}

.swatch-btn {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.swatch-btn.active {
  border-color: #fff;
  box-shadow: 0 0 0 1px var(--accent);
}

.edit-icon-btn {
  height: 28px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-strong);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.edit-icon-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.edit-icon-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.edit-icon-btn.danger {
  color: var(--down);
}

/* Bar Replay Floating Dock */
.replay-dock {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-glass);
  border: 1px solid var(--warn);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.replay-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-strong);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.replay-btn.play {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.replay-btn.exit {
  color: var(--down);
}

.replay-speed-btn {
  height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-strong);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.replay-progress {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  padding: 0 4px;
  white-space: nowrap;
}

/* Minimal Floating Recovery Controls (Auto / Jump-Latest) */
.chart-quick-controls {
  position: absolute;
  right: 66px;
  bottom: 30px;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 6px;
}

.quick-pill {
  height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-glass);
  color: var(--text-strong);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(8px);
}

.quick-pill.circle {
  width: 30px;
  height: 30px;
  padding: 0;
}

.chart-loading-pill {
  position: absolute;
  top: 10px;
  right: 70px;
  z-index: 10;
  background: var(--surface-glass);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Authentic TradingView Mobile Chart Action Bar */
.tv-chart-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  height: 46px;
  padding: 0 10px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.tv-sym-wheel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  height: 44px;
  min-width: 66px;
  max-width: 86px;
  padding: 0 4px;
  border: none;
  background: transparent;
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
}

.sym-wheel-ghost {
  font-size: 10px;
  line-height: 1;
  font-weight: 500;
  color: var(--text-muted);
  opacity: 0.38;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 78px;
}

.sym-wheel-cur {
  font-size: 15px;
  line-height: 1.25;
  font-weight: 700;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 78px;
}

.tv-tb-text {
  height: 36px;
  padding: 0 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-strong);
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.tv-tb-text:active {
  background: var(--surface-2);
}

.tv-tb-icon {
  position: relative;
  width: 38px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.tv-tb-icon:active {
  background: var(--surface-2);
}

.tv-tb-icon.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.tb-badge {
  position: absolute;
  top: 2px;
  right: 1px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tb-dot {
  position: absolute;
  top: 6px;
  right: 5px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--accent);
}

/* Authentic TradingView Mobile Bottom Tab Bar */
.bottom-nav {
  flex: 0 0 auto;
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}

.nav-btn {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 50px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
}

.nav-btn.active {
  color: var(--text-strong);
  font-weight: 700;
}

.nav-btn.replay-on {
  color: var(--warn);
}

.nav-btn.active .nav-svg-chart .nav-chart-box {
  fill: var(--text-strong);
  stroke: var(--text-strong);
}

.nav-btn.active .nav-svg-chart .nav-chart-line {
  stroke: var(--bg);
  stroke-width: 2.2;
}

/* Landscape Auto-Immersive Mode (TV Mobile style) */
@media (orientation: landscape) and (max-height: 540px) {
  .bottom-nav {
    display: none !important;
  }
  .tv-chart-toolbar {
    height: 38px;
    padding: 0 10px;
    padding-bottom: var(--safe-bottom);
  }
  .tv-sym-wheel {
    height: 34px;
  }
  .sym-wheel-ghost {
    display: none;
  }
  .tv-legend {
    top: 4px;
  }
}

/* Watchlist View (TV Mobile Style) */
.watchlist-view {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--bg);
}

.wl-header {
  flex: 0 0 auto;
  padding: 10px 12px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.wl-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.wl-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-strong);
}

.wl-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-strong);
  font-size: 15px;
  cursor: pointer;
}

.search-input {
  width: 100%;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-strong);
  padding: 0 12px;
  font-size: 14px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.search-input:focus {
  border-color: var(--accent);
}

.filter-tabs {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.filter-tab {
  flex: 1 1 0;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.filter-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.wl-col-head {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 68px 104px;
  align-items: center;
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.wl-col-spark { text-align: center; }
.wl-col-price { text-align: right; }

.watchlist-list {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.wl-item {
  display: grid;
  grid-template-columns: 1fr 68px 104px;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.wl-item:active {
  background: var(--surface);
}

.wl-item.active-sym {
  background: var(--accent-soft);
}

.wl-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.wl-star {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  padding: 4px 2px;
  cursor: pointer;
  flex-shrink: 0;
}

.wl-star.on {
  color: #f5b91a;
}

.wl-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-strong);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wl-meta {
  min-width: 0;
}

.wl-sym-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.wl-sym {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-strong);
}

.wl-provider {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
}

.wl-desc {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.wl-spark {
  display: flex;
  align-items: center;
  justify-content: center;
}

.wl-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  font-variant-numeric: tabular-nums;
}

.wl-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-strong);
}

.wl-chg-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  min-width: 62px;
  text-align: center;
}

.wl-chg-pill.up {
  color: var(--up);
  background: var(--up-bg);
}

.wl-chg-pill.down {
  color: var(--down);
  background: var(--down-bg);
}

.wl-chg-pill.flat {
  color: var(--text-muted);
  background: var(--surface-2);
}

/* Bottom Sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.sheet-panel {
  background: var(--surface);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border-top: 1px solid var(--border);
  max-height: 82dvh;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(14px + var(--safe-bottom));
  box-shadow: var(--shadow);
}

.sheet-grabber {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  margin: 8px auto 2px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.sheet-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-strong);
}

.sheet-close {
  border: none;
  background: var(--surface-2);
  color: var(--text);
  width: 30px;
  height: 30px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
}

.sheet-body {
  padding: 12px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet-section-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 12px 0 7px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.sheet-section-title:first-child {
  margin-top: 0;
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.chip-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.chip-grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.chip-btn {
  min-height: 38px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.chip-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chip-sub {
  font-size: 10.5px;
  opacity: 0.78;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.toggle-row:last-child {
  border-bottom: none;
}

.toggle-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
}

.toggle-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.switch {
  position: relative;
  width: 44px;
  height: 25px;
  border-radius: 999px;
  border: none;
  background: var(--surface-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.16s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 999px;
  background: #fff;
  transition: transform 0.16s ease;
}

.switch.on {
  background: var(--accent);
}

.switch.on::after {
  transform: translateX(19px);
}

.ma-config-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.ma-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.ma-select,
.ma-num-input,
.date-input {
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-strong);
  padding: 0 8px;
  font-size: 13px;
  outline: none;
}

.ma-num-input {
  width: 64px;
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
}

.date-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.date-input {
  flex: 1 1 auto;
  height: 38px;
}

.date-go-btn {
  height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.comp-sheet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.comp-sheet-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.comp-remove-btn {
  border: none;
  background: transparent;
  color: var(--down);
  font-size: 16px;
  padding: 4px 6px;
  cursor: pointer;
}

.add-comp-list {
  margin-top: 8px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.add-comp-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.add-comp-item:last-child {
  border-bottom: none;
}

.add-comp-item:active {
  background: var(--surface-2);
}

.draw-tool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.draw-tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-strong);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.draw-tool-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.draw-tool-ico {
  font-size: 20px;
  line-height: 1;
}

.danger-outline-btn {
  width: 100%;
  height: 38px;
  margin-top: 10px;
  border-radius: 10px;
  border: 1px solid var(--down);
  background: transparent;
  color: var(--down);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
