/**
 * Weather Lab — UI Redesign v2 (layered overrides on top of weather-lab.css)
 * Scope: tab bar + Data Collection tab. Other tabs land in later iterations.
 */

/* ──────────────────────────────────────────────
 * Icon base
 * ────────────────────────────────────────────── */
.wl-icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.wl-icon-inline { width: 1em; height: 1em; vertical-align: -0.15em; }

/* ──────────────────────────────────────────────
 * Single-row header: logo (left) | tab pill group (center) | actions (right)
 * Tab group is a contained rounded pill bar — active tab is a white card
 * with a blue dot prefix.
 * ────────────────────────────────────────────── */
.cb-header.cb-header-with-tabs {
  /* Grid (not flex) so logo and actions get EQUAL outer columns regardless
     of their content width. The center column is auto-sized — the tab pill
     inside it ends up exactly window-centered no matter how much space the
     logo/actions consume. With flex this was wrong: the pill was centered
     in "available space after logo+actions", which drifted left/right when
     the two sides had unequal widths. */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 84px;
  /* Same scrollbar-gutter compensation as before so the centered axis also
     matches the centered content card below (cb-main has stable gutter). */
  padding: 0 calc(var(--cb-spacing) + var(--scrollbar-w, 0px)) 0 var(--cb-spacing);
  gap: 20px;
  background: #ffffff;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}
.cb-header.cb-header-with-tabs .cb-header-logo { justify-self: start; }
.cb-header.cb-header-with-tabs .cb-header-actions { justify-self: end; }
[data-dark="true"] .cb-header.cb-header-with-tabs {
  background: #0b1220;
  border-bottom-color: rgba(148, 163, 184, 0.12);
}
.cb-header.cb-header-with-tabs .cb-header-logo {
  flex-shrink: 0;
  /* Bumped to match the new 48px action-row height; gap to title widened so
     the brand block reads as one cohesive unit instead of crowded glyphs. */
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: -8px;
  border-radius: 12px;
  transition: background 0.15s ease;
}
.cb-header.cb-header-with-tabs .cb-header-logo:hover {
  background: rgba(15, 23, 42, 0.04);
}
[data-dark="true"] .cb-header.cb-header-with-tabs .cb-header-logo:hover {
  background: rgba(255, 255, 255, 0.05);
}
.cb-header.cb-header-with-tabs .cb-header-logo img {
  /* `!important` to override weather-lab.css's compact rule (32px). */
  height: 40px !important;
}
/* Service title sits to the right of the logo image as a single brand block.
   Truncates on overflow rather than wrapping, and disappears entirely on
   narrow screens so the tab pill isn't squeezed below readable width. */
.cb-header.cb-header-with-tabs .cb-header-title {
  font-family: var(--cb-font-display);
  font-weight: 700;
  font-size: 1.08em;
  color: var(--cb-color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
[data-dark="true"] .cb-header.cb-header-with-tabs .cb-header-title {
  color: #e2e8f0;
}
@media (max-width: 1024px) {
  .cb-header.cb-header-with-tabs .cb-header-title { display: none; }
}
.cb-header.cb-header-with-tabs .cb-header-actions {
  flex-shrink: 0;
  gap: 6px;
  height: 48px;
  align-items: center;
}

/* Tab pill container — rounded, muted track, soft shadow.
 * Width matches the standard content container (800px) so the pill aligns
 * vertically with the section card below it. Centered between logo and
 * actions. Tabs inside distribute equally to fill the pill, giving a tidy
 * grid feel rather than four labels floating in a wide ribbon. */
.wl-tabs.wl-tabs--in-header {
  /* Content-sized: was flex/width 800px which forced four equal ~190px
     columns and truncated longer labels ("데이터 프로…"). Letting the
     pill grow to its natural width — each tab as wide as its label needs —
     guarantees every label is fully visible. The pill stays centered via
     the parent grid (1fr auto 1fr). */
  margin: 0 auto;
  padding: 6px;
  background: #f1f4f9;
  border: 1px solid rgba(15, 23, 42, 0.07);
  border-radius: 14px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
  scrollbar-width: none;
  /* 8 → 14px so the four labels read as clearly separate stops. */
  gap: 14px;
  display: flex;
  align-items: stretch;
  max-width: 100%;
}
.wl-tabs.wl-tabs--in-header::-webkit-scrollbar { display: none; }
[data-dark="true"] .wl-tabs.wl-tabs--in-header {
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.10);
  box-shadow: none;
}

/* Each tab: pill button with icon + label. Sized to its content (was equal
   1/4 column distribution which clipped long Korean labels). Generous
   horizontal padding gives clear breathing room around each label. */
.wl-tabs.wl-tabs--in-header .wl-tab-btn {
  flex: 0 0 auto;
  min-height: 44px;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--cb-color-text2);
  white-space: nowrap;
  border: none;
  background: transparent;
  transition: color 0.15s ease, background 0.15s ease;
  position: relative;
}
.wl-tabs.wl-tabs--in-header .wl-tab-btn:hover:not(.active) {
  color: var(--cb-color-text);
  background: rgba(255, 255, 255, 0.55);
}
[data-dark="true"] .wl-tabs.wl-tabs--in-header .wl-tab-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.04);
}
.wl-tabs.wl-tabs--in-header .wl-tab-btn .tab-step { display: none; }
.wl-tabs.wl-tabs--in-header .wl-tab-btn .wl-icon {
  width: 17px; height: 17px; flex-shrink: 0;
  opacity: 0.85;
}
.wl-tabs.wl-tabs--in-header .wl-tab-btn .tab-label {
  font-size: 13.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Active tab: white pill with blue-dot prefix and soft shadow. */
.wl-tabs.wl-tabs--in-header .wl-tab-btn.active {
  background: #ffffff;
  color: var(--cb-color-primary);
  font-weight: 600;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.06),
    0 4px 10px -4px rgba(15, 23, 42, 0.10);
}
.wl-tabs.wl-tabs--in-header .wl-tab-btn.active .wl-icon { opacity: 1; }
.wl-tabs.wl-tabs--in-header .wl-tab-btn.active::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--cb-color-primary);
  border-radius: 50%;
  flex-shrink: 0;
  margin-right: 1px;
}
[data-dark="true"] .wl-tabs.wl-tabs--in-header .wl-tab-btn.active {
  background: #1e293b;
  color: #93c5fd;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
[data-dark="true"] .wl-tabs.wl-tabs--in-header .wl-tab-btn.active::before {
  background: #93c5fd;
}

/* Header icon buttons (help / language / theme / settings). Larger touch
   target: was 36px → now 44px (matches tab height) so the whole header reads
   as a row of consistent-sized controls. `!important` is required because
   the older weather-lab.css base layer sets `.cb-header-btn` size with
   `!important` itself; this is the v2 override taking precedence. */
.cb-header.cb-header-with-tabs .cb-header-btn,
.cb-header.cb-header-with-tabs .wl-dark-toggle {
  width: 44px !important;
  height: 44px !important;
  border-radius: 11px;
  color: var(--cb-color-text2);
  transition: background 0.15s ease, color 0.15s ease;
}
/* Bump the icon size inside header buttons to match the larger container. */
.cb-header.cb-header-with-tabs .cb-header-btn svg,
.cb-header.cb-header-with-tabs .wl-dark-toggle svg {
  width: 22px;
  height: 22px;
}
.cb-header.cb-header-with-tabs .cb-header-btn:hover,
.cb-header.cb-header-with-tabs .wl-dark-toggle:hover {
  background: rgba(15, 23, 42, 0.06);
  color: var(--cb-color-primary);
}
[data-dark="true"] .cb-header.cb-header-with-tabs .cb-header-btn:hover,
[data-dark="true"] .cb-header.cb-header-with-tabs .wl-dark-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* BLE pill — slim, matches button row. */
.cb-header.cb-header-with-tabs .cb-ble-pill {
  height: 36px;
  padding: 0 14px;
  margin-left: 6px;
  border-width: 1px;
  border-radius: 18px;
  font-size: 12px;
  font-weight: 600;
  background: var(--cb-color-bg);
}

/* Narrow screens: tabs wrap below logo+actions row, full-width inside header. */
@media (max-width: 960px) {
  .cb-header.cb-header-with-tabs {
    flex-wrap: wrap;
    height: auto !important;
    min-height: 56px;
    padding: 8px var(--cb-spacing);
    gap: 8px;
  }
  .cb-header.cb-header-with-tabs .cb-header-actions { margin-left: auto; }
  .wl-tabs.wl-tabs--in-header {
    order: 3;
    flex-basis: 100%;
    margin: 0;
  }
  .wl-tabs.wl-tabs--in-header .wl-tab-btn {
    flex: 1 1 0;
    padding: 6px 10px;
    font-size: 12.5px;
  }
}

/* ──────────────────────────────────────────────
 * Tab bar — numbered flow with icons (FALLBACK when not hoisted)
 * ────────────────────────────────────────────── */
.wl-tabs {
  display: flex;
  gap: 4px;
  padding: 6px;
  background: var(--cb-color-bg);
  border-radius: 16px;
  margin-bottom: 22px;
  border: 1px solid var(--cb-color-border);
}
.wl-tab-btn {
  flex: 1;
  min-height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 6px;
  background: transparent;
  border: none;
  border-bottom: none;        /* override default underline tab style */
  border-radius: 12px;
  color: var(--cb-color-text2);
  font-family: var(--cb-font-display);
  font-size: 0.92em;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, transform .12s;
  position: relative;
}
.wl-tab-btn:hover { background: var(--cb-color-primary-light); color: var(--cb-color-primary); }
.wl-tab-btn.active {
  background: var(--cb-color-primary);
  color: #fff;
  border-bottom: none;
  box-shadow: 0 6px 16px rgba(74,127,224,0.30);
}
.wl-tab-btn.active:hover { background: var(--cb-color-primary); color: #fff; }
.wl-tab-btn .tab-step {
  font-size: 0.62em;
  font-weight: 700;
  letter-spacing: 0.12em;
  opacity: 0.65;
  text-transform: uppercase;
  line-height: 1;
}
.wl-tab-btn .tab-label { font-size: 0.96em; line-height: 1.1; }
.wl-tab-btn .wl-icon { width: 22px; height: 22px; }

/* ──────────────────────────────────────────────
 * Tab content header — eyebrow + H1
 * ────────────────────────────────────────────── */
.wl-tab-header {
  margin: 4px 4px 18px;
}
.wl-tab-header .tab-eyebrow {
  font-family: var(--cb-font-display);
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--cb-color-primary);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.wl-tab-header .tab-title {
  font-family: var(--cb-font-display);
  font-size: 1.85em;
  font-weight: 800;
  color: var(--cb-color-text);
  line-height: 1.15;
  margin: 0;
}
[data-dark="true"] .wl-tab-header .tab-title { color: #f1f5f9; }

/* ──────────────────────────────────────────────
 * City cards — visual selector with weather icons
 * ────────────────────────────────────────────── */
.wl-city-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
/* ──────────────────────────────────────────────
 * Scientific-method panel (Analyze tab)
 * Three numbered steps (Hypothesis → Observation → Conclusion) with a soft
 * gradient accent. Numbers act as visual anchors so the student understands
 * the order without reading the labels.
 * ────────────────────────────────────────────── */
.wl-science-card { padding: 18px; }
.wl-science-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.wl-science-step + .wl-science-step { margin-top: 16px; }
.wl-science-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #a855f7, #ec4899);
  color: #fff;
  font-family: var(--cb-font-display);
  font-weight: 800;
  font-size: 0.92em;
  margin-top: 2px;
}
.wl-science-body { flex: 1; min-width: 0; }
.wl-science-label {
  display: block;
  font-family: var(--cb-font-display);
  font-weight: 700;
  font-size: 0.95em;
  color: var(--cb-color-text);
  margin-bottom: 6px;
}
[data-dark="true"] .wl-science-label { color: #e2e8f0; }
.wl-science-textarea {
  width: 100%;
  min-height: 70px;
  resize: vertical;
  padding: 10px 12px;
  border: 1.5px solid var(--cb-color-border);
  border-radius: 10px;
  font-family: var(--cb-font-body);
  font-size: 0.95em;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
  background: #fff;
  color: var(--cb-color-text);
}
[data-dark="true"] .wl-science-textarea {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}
.wl-science-textarea:focus {
  border-color: #a855f7;
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

/* ──────────────────────────────────────────────
 * Compare-mode chart toggles (option B): pill buttons grouped into
 * "series" and "metric" rows above the chart. Active = filled, inactive =
 * outlined+muted. Each click flips the state and the underlying dataset
 * shows/hides via chart.show()/hide(). Visual hierarchy:
 *   - Series pill: colored dot + label
 *   - Metric pill: line-style preview + label
 * ────────────────────────────────────────────── */
.wl-chart-toggles { margin: 4px 2px 12px; }
.wl-chart-toggles:empty { display: none; }
.wl-tg-section + .wl-tg-section { margin-top: 8px; }
.wl-tg-label {
  font-size: 0.72em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--cb-color-text2);
  margin-bottom: 6px;
}
.wl-tg-row { display: flex; flex-wrap: wrap; gap: 6px; }
.wl-tg-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--cb-color-border);
  background: #fff;
  color: var(--cb-color-text2);
  font-family: var(--cb-font-display);
  font-size: 0.85em;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, transform .1s, opacity .15s;
  user-select: none;
}
.wl-tg-chip:hover { transform: translateY(-1px); }
.wl-tg-chip:not(.is-on) { opacity: 0.55; background: var(--cb-color-bg); }
[data-dark="true"] .wl-tg-chip { background: #0f172a; border-color: #334155; color: #94a3b8; }
[data-dark="true"] .wl-tg-chip:not(.is-on) { background: #0b1220; opacity: 0.5; }
/* Series chip uses the dataset color in `--chip` to highlight on active. */
.wl-tg-chip--series.is-on { color: #fff; border-color: var(--chip); background: var(--chip); }
.wl-tg-chip--metric.is-on { color: var(--cb-color-text); border-color: var(--cb-color-primary); background: var(--cb-color-primary-light); }
[data-dark="true"] .wl-tg-chip--metric.is-on { color: #f1f5f9; background: rgba(96,165,250,0.15); border-color: #60a5fa; }
.wl-tg-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
/* Line-style miniature for metric chips */
.wl-tg-line { display: inline-block; width: 18px; height: 0; border-top: 2.4px solid currentColor; flex-shrink: 0; }
.wl-tg-line--solid  { border-top-style: solid; border-top-width: 2.6px; }
.wl-tg-line--dashed { border-top-style: dashed; border-top-width: 2px; }
.wl-tg-line--dotted { border-top-style: dotted; border-top-width: 2px; }

/* Subtle hint under the city-search input clarifying that English queries
   give the most reliable matches (the Open-Meteo geocoder indexes city names
   in their native script/English, so Korean queries hit-or-miss). */
.wl-city-search-hint {
  font-size: 0.78em;
  color: var(--cb-color-text2);
  margin: 4px 2px 8px;
  line-height: 1.4;
}
[data-dark="true"] .wl-city-search-hint { color: #94a3b8; }

/* Custom-search results: empty by default — collapse the row so it doesn't
   leave a 12px gap below the example cities until something is added. */
.wl-city-cards--custom:empty { display: none; }
/* Use flex (not grid) so a single custom chip sizes to its content instead
   of stretching to fill the entire row. Items match example city chip width
   via min/max widths consistent with the grid track sizes above. */
.wl-city-cards--custom {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
/* Match the visual treatment of example chips so single + custom rows blend
   seamlessly: same compact padding, font weight, pill border-radius, and
   muted neutral state. The `.active` selector below paints the selected chip. */
.wl-city-cards--custom > .wl-city-card {
  min-width: 88px;
  max-width: 240px;
  flex: 0 1 auto;
  padding: 8px 10px;
  font-size: 0.84em;
  font-weight: 500;
  border-width: 1px;
  border-color: rgba(0,56,69,0.10);
  background: rgba(255,255,255,0.5);
  color: var(--cb-color-text2);
  border-radius: 999px;
  box-shadow: none;
}
[data-dark="true"] .wl-city-cards--custom > .wl-city-card {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.10);
  color: #94a3b8;
}
.wl-city-cards--custom > .wl-city-card:hover {
  border-color: var(--cb-color-primary);
  background: var(--cb-color-primary-light);
  color: var(--cb-color-primary);
  box-shadow: none;
  transform: none;
}
.wl-city-cards--custom > .wl-city-card.active {
  background: var(--cb-color-primary-light);
  color: var(--cb-color-primary);
  border-color: var(--cb-color-primary);
  box-shadow: 0 0 0 1px var(--cb-color-primary);
}
[data-dark="true"] .wl-city-cards--custom > .wl-city-card.active {
  background: rgba(96,165,250,0.12);
  color: #93c5fd;
  border-color: #60a5fa;
}
/* Compact "remove" badge on custom chips. Designed to read on both the
   neutral idle state AND the saturated blue active state — solid white pill
   with a strong dark X stays legible against either background. */
.wl-city-chip--custom { position: relative; padding-right: 28px; }
.wl-city-chip-remove {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  line-height: 16px;
  text-align: center;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 800;
  color: #475569;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.12);
  cursor: pointer;
  transition: background .12s, color .12s, transform .12s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.10);
}
.wl-city-chip-remove:hover {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
  transform: translateY(-50%) scale(1.1);
}
[data-dark="true"] .wl-city-chip-remove {
  background: #e2e8f0;
  color: #1e293b;
  border-color: rgba(0,0,0,0.18);
}
.wl-city-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 10px;
  background: #fff;
  border: 1.5px solid var(--cb-color-border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .12s, box-shadow .15s, color .15s;
  font-family: var(--cb-font-body);
  font-size: 0.95em;
  font-weight: 600;
  color: var(--cb-color-text);
}
[data-dark="true"] .wl-city-card { background: #1e293b; color: #e2e8f0; }

.wl-city-card:hover {
  border-color: var(--cb-color-primary);
  color: var(--cb-color-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(74,127,224,0.12);
}

.wl-city-card.active {
  background: var(--cb-color-primary);
  color: #fff;
  border-color: var(--cb-color-primary);
  box-shadow: 0 6px 18px rgba(74,127,224,0.32);
}

/* ──────────────────────────────────────────────
 * Data Collection — combined Setup card
 * ────────────────────────────────────────────── */
.wl-setup-card {
  background: linear-gradient(160deg, #ffffff 0%, var(--cb-color-primary-light) 110%);
  border: 1.5px solid var(--cb-color-border);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.04);
}
[data-dark="true"] .wl-setup-card {
  background: linear-gradient(160deg, #1e293b 0%, #1a2436 100%);
  border-color: #2a3a52;
}

.wl-setup-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-family: var(--cb-font-display);
  font-size: 1.1em;
  font-weight: 700;
  color: var(--cb-color-primary);
}
.wl-setup-header .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--cb-color-primary);
  color: #fff;
  border-radius: 50%;
  font-size: 0.9em;
  font-weight: 700;
}

/* Mode tabs at top of setup card */
.wl-mode-tabs {
  display: inline-flex;
  background: var(--cb-color-bg);
  border: 1px solid var(--cb-color-border);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 16px;
}
.wl-mode-btn {
  background: transparent;
  border: none;
  padding: 7px 14px;
  border-radius: 7px;
  font-family: var(--cb-font-display);
  font-weight: 700;
  font-size: 0.88em;
  color: var(--cb-color-text2);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.wl-mode-btn:hover { color: var(--cb-color-primary); }
.wl-mode-btn.active {
  background: var(--cb-color-primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(74,127,224,0.30);
}
[data-dark="true"] .wl-mode-btn.active { background: #2563eb; }

/* Year chips for year-compare mode */
.wl-year-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.wl-year-chip {
  padding: 7px 14px;
  background: #fff;
  border: 1.5px solid var(--cb-color-border);
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--cb-font-display);
  font-weight: 600;
  font-size: 0.92em;
  color: var(--cb-color-text);
  transition: all .15s;
}
[data-dark="true"] .wl-year-chip { background: #1e293b; color: #e2e8f0; }
.wl-year-chip:hover { border-color: var(--cb-color-primary); color: var(--cb-color-primary); }
.wl-year-chip.active {
  background: var(--cb-color-primary);
  color: #fff;
  border-color: var(--cb-color-primary);
}
/* "Show earlier years" expander chip — dashed border + muted color so it
   reads as a control rather than a selectable year. Sits at the start of
   the row so the visual flow is "+ 이전 10년 | 2017 2018 2019 …". */
.wl-year-chip--more {
  border-style: dashed;
  color: var(--cb-color-text2);
}
.wl-year-chip--more:hover {
  border-style: solid;
  background: var(--cb-color-primary-light);
}
.wl-month-select {
  padding: 10px 14px;
  border: 1.5px solid var(--cb-color-border);
  border-radius: 10px;
  font-size: 0.95em;
  font-family: var(--cb-font-display);
  font-weight: 600;
  background: #fff;
  cursor: pointer;
}
[data-dark="true"] .wl-month-select { background: #1e293b; color: #e2e8f0; border-color: #334155; }

/* Series comparison table (used in summary card for compare modes) */
.wl-cmp-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--cb-color-border);
  border-radius: 12px;
}
.wl-cmp-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--cb-font-body);
  font-size: 0.92em;
}
.wl-cmp-table th {
  background: var(--cb-color-primary);
  color: #fff;
  padding: 10px 12px;
  text-align: center;
  font-weight: 700;
  font-size: 0.86em;
  white-space: nowrap;
}
.wl-cmp-table td {
  padding: 10px 12px;
  text-align: center;
  border-bottom: 1px solid var(--cb-color-border);
  white-space: nowrap;
}
.wl-cmp-table tr:last-child td { border-bottom: none; }
.wl-cmp-table tr:hover td { background: var(--cb-color-primary-light); }
[data-dark="true"] .wl-cmp-table td { border-bottom-color: #334155; color: #e2e8f0; }
[data-dark="true"] .wl-cmp-table tr:hover td { background: rgba(96,165,250,0.10); }

/* Series selector above the data table (compare modes only) */
.wl-table-series-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding: 8px 0;
}
.wl-table-series-label {
  font-size: 0.85em;
  font-weight: 700;
  color: var(--cb-color-text2);
  margin-right: 4px;
}
.wl-table-series-btn {
  padding: 6px 12px;
  background: #fff;
  border: 1.5px solid var(--cb-color-border);
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--cb-font-display);
  font-weight: 600;
  font-size: 0.85em;
  color: var(--cb-color-text2);
  transition: all .15s;
}
[data-dark="true"] .wl-table-series-btn { background: #1e293b; color: #cbd5e1; border-color: #334155; }
.wl-table-series-btn:hover { border-color: var(--cb-color-primary); color: var(--cb-color-primary); }
.wl-table-series-btn.active {
  background: var(--cb-color-primary);
  color: #fff;
  border-color: var(--cb-color-primary);
}

/* City compare allows multi-select on existing cards */
[data-mode-form="city"] .wl-city-card.cmp-selected {
  outline: 2px solid var(--cb-color-primary);
  outline-offset: 2px;
}

.wl-setup-section {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px dashed var(--cb-color-border);
}
.wl-setup-section:last-of-type {
  margin-bottom: 18px;
  padding-bottom: 0;
  border-bottom: none;
}
.wl-setup-section .section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--cb-font-display);
  font-size: 0.78em;
  font-weight: 700;
  color: var(--cb-color-text2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}
.wl-setup-section .section-title .wl-icon { width: 14px; height: 14px; }

/* City chips — flatter, no emoji */
.wl-quick-cities {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.wl-city-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: #fff;
  color: var(--cb-color-text);
  border: 1.5px solid var(--cb-color-border);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
  font-size: 0.92em;
  font-weight: 500;
  font-family: var(--cb-font-body);
}
[data-dark="true"] .wl-city-chip { background: #1e293b; color: #e2e8f0; }
.wl-city-chip:hover { border-color: var(--cb-color-primary); color: var(--cb-color-primary); }
.wl-city-chip.active {
  background: var(--cb-color-primary);
  color: #fff;
  border-color: var(--cb-color-primary);
}

/* Inline search row */
.wl-city-search {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.wl-city-search input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--cb-color-border);
  border-radius: 10px;
  font-size: 0.95em;
  outline: none;
  background: #fff;
  color: var(--cb-color-text);
}
[data-dark="true"] .wl-city-search input { background: #1e293b; color: #e2e8f0; }
.wl-city-search input:focus { border-color: var(--cb-color-primary); }
.wl-city-search button {
  padding: 0 16px;
  background: var(--cb-color-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Prominent search — primary input for picking any city worldwide */
.wl-city-search--prominent {
  margin: 0 0 14px;
  position: relative;
}
.wl-city-search--prominent input {
  padding: 14px 16px 14px 44px;
  border-radius: 12px;
  border-width: 2px;
  font-size: 1.02em;
  font-weight: 500;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0,107,125,0.06);
  transition: border-color .18s, box-shadow .18s, transform .12s;
}
.wl-city-search--prominent input::placeholder {
  color: #97A6B1;
  font-weight: 400;
}
.wl-city-search--prominent input:focus {
  border-color: var(--cb-color-primary);
  box-shadow: 0 0 0 4px rgba(0,107,125,0.10), 0 6px 18px rgba(0,107,125,0.12);
}
.wl-city-search--prominent::before {
  content: '';
  position: absolute;
  top: 50%; left: 16px;
  width: 18px; height: 18px;
  transform: translateY(-50%);
  background: currentColor;
  color: #97A6B1;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>') no-repeat center / contain;
          mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>') no-repeat center / contain;
  pointer-events: none;
}
.wl-city-search--prominent button {
  padding: 0 22px;
  border-radius: 12px;
  font-size: 0.98em;
  font-weight: 700;
  background: linear-gradient(135deg, #007A8D 0%, #006B7D 100%);
  box-shadow: 0 4px 12px rgba(0,107,125,0.28);
  transition: transform .12s, box-shadow .18s;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 88px;
}
.wl-city-search--prominent button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,107,125,0.36);
}

/* Example city cards — quieter, secondary suggestion */
.wl-quick-cities-wrap {
  margin: 4px 0 6px;
}
.wl-quick-cities-label {
  display: block;
  font-family: var(--cb-font-display);
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cb-color-text2);
  opacity: 0.75;
  margin: 0 0 8px 2px;
}
.wl-city-cards--examples {
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 6px;
}
.wl-city-cards--examples .wl-city-card {
  padding: 8px 10px;
  font-size: 0.84em;
  font-weight: 500;
  border-width: 1px;
  border-color: rgba(0,56,69,0.10);
  background: rgba(255,255,255,0.5);
  color: var(--cb-color-text2);
  border-radius: 999px;
  box-shadow: none;
}
[data-dark="true"] .wl-city-cards--examples .wl-city-card {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.10);
  color: #94a3b8;
}
.wl-city-cards--examples .wl-city-card:hover {
  border-color: var(--cb-color-primary);
  background: var(--cb-color-primary-light);
  color: var(--cb-color-primary);
  box-shadow: none;
  transform: none;
}
.wl-city-cards--examples .wl-city-card.active {
  background: var(--cb-color-primary-light);
  color: var(--cb-color-primary);
  border-color: var(--cb-color-primary);
  box-shadow: 0 0 0 1px var(--cb-color-primary);
}
[data-dark="true"] .wl-city-cards--examples .wl-city-card.active {
  background: rgba(96,165,250,0.12);
  color: #93c5fd;
  border-color: #60a5fa;
}
/* Compare mode no longer adds an extra outline — `.active` styling alone
   matches the single-mode "selected" look so the chosen chips are visually
   consistent across all three setup modes. */

.wl-selected-city {
  margin-top: 10px;
  font-family: var(--cb-font-display);
  font-size: 0.95em;
  font-weight: 600;
  color: var(--cb-color-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Date presets */
.wl-date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}
.wl-preset-chip {
  background: #fff;
  color: var(--cb-color-text2);
  border: 1px solid var(--cb-color-border);
  border-radius: 8px;
  padding: 5px 11px;
  font-size: 0.85em;
  cursor: pointer;
  font-family: var(--cb-font-body);
  transition: border-color .15s, color .15s;
}
[data-dark="true"] .wl-preset-chip { background: #1e293b; color: #cbd5e1; }
.wl-preset-chip:hover { border-color: var(--cb-color-primary); color: var(--cb-color-primary); }

.wl-date-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.wl-date-row input[type="date"] {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--cb-color-border);
  border-radius: 10px;
  font-size: 0.95em;
  outline: none;
  background: #fff;
  color: var(--cb-color-text);
  font-family: inherit;
}
[data-dark="true"] .wl-date-row input[type="date"] { background: #1e293b; color: #e2e8f0; }
.wl-date-row input[type="date"]:focus { border-color: var(--cb-color-primary); }
.wl-date-row .date-sep { color: var(--cb-color-text2); font-weight: 700; font-size: 1.2em; }

/* Primary CTA — emphasized fetch button */
.wl-cta-btn {
  width: 100%;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--cb-color-primary), #5b8fe8);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-family: var(--cb-font-display);
  font-size: 1.18em;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 8px 22px rgba(74,127,224,0.35);
  transition: transform .12s, box-shadow .15s;
  letter-spacing: 0.01em;
}
.wl-cta-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(74,127,224,0.45); }
.wl-cta-btn:active { transform: translateY(0); box-shadow: 0 4px 14px rgba(74,127,224,0.30); }
.wl-cta-btn .wl-icon { width: 22px; height: 22px; }

/* ──────────────────────────────────────────────
 * Compact CSV uploader (collapsible)
 * ────────────────────────────────────────────── */
.wl-csv-compact {
  background: var(--cb-color-bg);
  border: 1px dashed var(--cb-color-border);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
}
.wl-csv-compact > summary {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--cb-font-display);
  font-weight: 600;
  color: var(--cb-color-text2);
  font-size: 0.92em;
  list-style: none;
  user-select: none;
}
.wl-csv-compact > summary::-webkit-details-marker { display: none; }
.wl-csv-compact > summary .wl-icon { width: 16px; height: 16px; }
.wl-csv-compact > summary .chev {
  margin-left: auto;
  transition: transform .2s;
}
.wl-csv-compact[open] > summary .chev { transform: rotate(180deg); }
.wl-csv-compact .csv-body {
  padding: 4px 16px 16px;
  border-top: 1px solid var(--cb-color-border);
}
.wl-csv-compact .wl-upload-zone {
  padding: 18px;
  margin-top: 8px;
  text-align: center;
}
.wl-csv-compact .wl-upload-zone .upload-text { font-size: 0.95em; }
.wl-csv-compact .wl-upload-zone .upload-hint { font-size: 0.8em; }

/* ──────────────────────────────────────────────
 * Results banner — visible IMMEDIATELY after fetch
 * ────────────────────────────────────────────── */
.wl-results-banner {
  display: none;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #d4f0e0, #a8e0c0);
  border-radius: 14px;
  margin-bottom: 16px;
  border-left: 4px solid #06d6a0;
  animation: wlSlideIn .25s ease-out;
}
@keyframes wlSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.wl-results-banner.show { display: flex; }
[data-dark="true"] .wl-results-banner {
  background: linear-gradient(135deg, #134e4a, #115e59);
  color: #d1fae5;
}
.wl-results-banner > .wl-icon {
  width: 28px;
  height: 28px;
  color: #0b7285;
  flex-shrink: 0;
}
[data-dark="true"] .wl-results-banner > .wl-icon { color: #6ee7b7; }
.wl-results-banner .results-meta { flex: 1; min-width: 0; }
.wl-results-banner .results-title {
  font-family: var(--cb-font-display);
  font-size: 1.05em;
  font-weight: 700;
  color: #0b7285;
}
[data-dark="true"] .wl-results-banner .results-title { color: #d1fae5; }
.wl-results-banner .results-sub {
  font-size: 0.85em;
  color: #0b7285;
  opacity: 0.85;
  margin-top: 2px;
}
.wl-results-banner .wl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #fff;
  color: #0b7285;
  border: 1px solid #0b7285;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9em;
  cursor: pointer;
  flex-shrink: 0;
}
.wl-results-banner .wl-btn:hover { background: #f0fdf4; }

/* ──────────────────────────────────────────────
 * Stats grid — bigger numbers, icon chips (no emoji)
 * ────────────────────────────────────────────── */
.wl-stat-box .stat-icon {
  font-size: inherit;
  margin: 0;
}
.wl-stat-box .stat-icon-wrap {
  width: 38px;
  height: 38px;
  margin: 0 auto 8px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--cb-color-primary-light);
  color: var(--cb-color-primary);
}
.wl-stat-box .stat-icon-wrap .wl-icon { width: 20px; height: 20px; }

.wl-stat-box.stat-hot   .stat-icon-wrap { background: #ffe3e3; color: #c92a2a; }
.wl-stat-box.stat-cold  .stat-icon-wrap { background: #d0ebff; color: #1864ab; }
.wl-stat-box.stat-avg   .stat-icon-wrap { background: #fff3bf; color: #b45309; }
.wl-stat-box.stat-rain  .stat-icon-wrap { background: #d0ebff; color: #1864ab; }
.wl-stat-box.stat-rainy .stat-icon-wrap { background: #d3f9d8; color: #0b7285; }
.wl-stat-box.stat-wind  .stat-icon-wrap { background: #d3f9d8; color: #06803a; }

/* Table card title icon row */
.wl-card-title .wl-icon { width: 18px; height: 18px; }
.wl-card-title .title-text { display: inline-flex; align-items: center; gap: 8px; }

/* ──────────────────────────────────────────────
 * Loading / error tweaks
 * ────────────────────────────────────────────── */
.wl-loading { padding: 28px 20px; }
.wl-loading .spinner { width: 36px; height: 36px; }
.wl-error-box {
  border-radius: 12px;
  padding: 12px 16px;
  display: none;
}
.wl-error-box.show { display: flex; align-items: center; gap: 8px; }

/* Hide noisy ".csvLoadedInfo" badge — moved into results-banner */
#csvLoadedInfo:empty { display: none; }

/* ──────────────────────────────────────────────
 * Analysis tab — Key Findings dashboard
 * ────────────────────────────────────────────── */
.wl-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 4px 12px;
}
/* Sections inside the Analyze tab were running into each other (Insights →
   Hypothesis → Charts → Observe/Conclude → Worksheet). Push them apart so
   the visual flow reads as distinct steps, not one long ribbon. */
#wl-tab-analysis section + section { margin-top: 36px; }
.wl-section-header .section-icon {
  width: 36px; height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Circle (not rounded square) when the icon doubles as a step-number badge
     so it reads as a numbered step rather than a UI tile. The per-section
     gradient is set inline on each <span> so steps remain visually distinct
     while the number text inside conveys order. */
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cb-color-primary), #8b5cf6);
  color: #fff;
  flex-shrink: 0;
  font-family: var(--cb-font-display);
  font-weight: 800;
  font-size: 1.05em;
  letter-spacing: -0.5px;
}
.wl-section-header .section-icon .wl-icon { width: 20px; height: 20px; }
.wl-section-header .section-title {
  font-family: var(--cb-font-display);
  font-size: 1.25em;
  font-weight: 800;
  color: var(--cb-color-text);
  line-height: 1.1;
}
/* Step number now lives inside the gradient `.section-icon` circle (option
   C), so the inline title-tag is redundant and hidden. Class kept defined
   for back-compat with any saved DOM that still has the span. */
.wl-step-tag { display: none; }
.wl-section-header .section-sub {
  font-size: 0.85em;
  color: var(--cb-color-text2);
  margin-top: 2px;
}
[data-dark="true"] .wl-section-header .section-title { color: #f1f5f9; }

.wl-insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.wl-insight-card {
  background: #fff;
  border: 1.5px solid var(--cb-color-border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .15s, transform .12s, box-shadow .15s;
  position: relative;
  overflow: hidden;
}
[data-dark="true"] .wl-insight-card { background: #1e293b; border-color: #334155; }
.wl-insight-card:hover {
  border-color: var(--cb-color-primary);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(74,127,224,0.12);
}

.wl-insight-card .insight-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.wl-insight-card .insight-icon {
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--cb-color-primary-light);
  color: var(--cb-color-primary);
  flex-shrink: 0;
}
.wl-insight-card .insight-icon .wl-icon { width: 18px; height: 18px; }
.wl-insight-card .insight-label {
  font-size: 0.85em;
  font-weight: 600;
  color: var(--cb-color-text2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.wl-insight-card .insight-value {
  font-family: var(--cb-font-display);
  font-size: 1.85em;
  font-weight: 800;
  color: var(--cb-color-primary);
  line-height: 1.1;
}
.wl-insight-card .insight-meta {
  font-size: 0.85em;
  color: var(--cb-color-text2);
}

/* Themed accent per insight category */
.wl-insight-card.insight-hot    .insight-icon { background: #ffe3e3; color: #c92a2a; }
.wl-insight-card.insight-hot    .insight-value { color: #c92a2a; }
.wl-insight-card.insight-cold   .insight-icon { background: #d0ebff; color: #1864ab; }
.wl-insight-card.insight-cold   .insight-value { color: #1864ab; }
.wl-insight-card.insight-rain   .insight-icon { background: #d0ebff; color: #1864ab; }
.wl-insight-card.insight-trend-up    .insight-icon { background: #fff3bf; color: #b45309; }
.wl-insight-card.insight-trend-up    .insight-value { color: #b45309; }
.wl-insight-card.insight-trend-down  .insight-icon { background: #d0ebff; color: #1864ab; }
.wl-insight-card.insight-trend-down  .insight-value { color: #1864ab; }
.wl-insight-card.insight-trend-flat  .insight-icon { background: var(--cb-color-bg); color: var(--cb-color-text2); }
.wl-insight-card.insight-trend-flat  .insight-value { color: var(--cb-color-text); }
.wl-insight-card.insight-rainy  .insight-icon { background: #d3f9d8; color: #0b7285; }
.wl-insight-card.insight-rainy  .insight-value { color: #0b7285; }
.wl-insight-card.insight-range  .insight-icon { background: #f3d9fa; color: #862e9c; }
.wl-insight-card.insight-range  .insight-value { color: #862e9c; }

/* Empty state when no data fetched */
.wl-empty-state {
  background: var(--cb-color-bg);
  border: 1.5px dashed var(--cb-color-border);
  border-radius: 18px;
  padding: 36px 24px;
  text-align: center;
  margin-top: 8px;
}
.wl-empty-state .empty-icon {
  width: 64px; height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--cb-color-primary-light);
  color: var(--cb-color-primary);
  margin-bottom: 14px;
}
.wl-empty-state .empty-icon .wl-icon { width: 32px; height: 32px; }
.wl-empty-state .empty-title {
  font-family: var(--cb-font-display);
  font-size: 1.15em;
  font-weight: 700;
  color: var(--cb-color-text);
  margin-bottom: 6px;
}
[data-dark="true"] .wl-empty-state .empty-title { color: #f1f5f9; }
.wl-empty-state .empty-sub {
  font-size: 0.92em;
  color: var(--cb-color-text2);
  margin-bottom: 16px;
  line-height: 1.5;
}
.wl-empty-state .wl-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--cb-color-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95em;
  cursor: pointer;
}
.wl-empty-state .wl-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(74,127,224,0.30); }

/* ──────────────────────────────────────────────
 * Scratch-style block coding (Robot/Code tab)
 * Color tokens by category (Scratch convention):
 *   Event   yellow  #ffbf00
 *   Control orange  #ff8c1a
 *   Sensing cyan    #5cb1d6
 *   Operator green  #59c059
 *   Action  purple  #9966ff
 * ────────────────────────────────────────────── */

/* Data context banner above the rules */
.wl-rules-context {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--cb-color-primary-light);
  border: 1px solid var(--cb-color-border);
  border-radius: 12px;
  margin-bottom: 12px;
}
.wl-rules-context .ctx-icon {
  width: 36px; height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--cb-color-primary);
  color: #fff;
  flex-shrink: 0;
}
.wl-rules-context .ctx-icon .wl-icon { width: 20px; height: 20px; }
.wl-rules-context .ctx-text { flex: 1; min-width: 0; }
.wl-rules-context .ctx-title {
  font-family: var(--cb-font-display);
  font-size: 0.92em;
  font-weight: 700;
  color: var(--cb-color-text);
}
[data-dark="true"] .wl-rules-context .ctx-title { color: #f1f5f9; }
.wl-rules-context .ctx-sub {
  font-size: 0.82em;
  color: var(--cb-color-text2);
  margin-top: 2px;
}
.wl-rules-context.empty {
  background: #fff3bf;
  border-color: #ffd43b;
}
.wl-rules-context .wl-ctx-go {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}
.wl-rules-context .wl-ctx-go .wl-icon { width: 14px; height: 14px; }
[data-dark="true"] .wl-rules-context.empty {
  background: #4d3e0e;
  border-color: #8a6914;
}

/* Connect-blocks CTA — prominent button to remind students to pair BLE */
.wl-connect-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #06d6a0, #0ea5e9);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: var(--cb-font-display);
  font-weight: 700;
  font-size: 0.95em;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(14,165,233,0.30);
  transition: transform .12s, box-shadow .15s;
}
.wl-connect-cta:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(14,165,233,0.40); }
.wl-connect-cta .wl-icon { width: 18px; height: 18px; }

/* Add-rule palette (Scratch-style category buttons) */
.wl-block-palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 14px;
}
.wl-palette-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  color: #fff;
  font-family: var(--cb-font-display);
  font-weight: 700;
  font-size: 0.92em;
  cursor: pointer;
  transition: transform .12s, filter .15s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.10);
}
.wl-palette-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.wl-palette-btn .wl-icon { width: 16px; height: 16px; }
.wl-palette-btn.cat-temp { background: linear-gradient(135deg, #ff6b6b, #fa5252); }
.wl-palette-btn.cat-rain { background: linear-gradient(135deg, #339af0, #228be6); }
.wl-palette-btn.cat-wind { background: linear-gradient(135deg, #06d6a0, #0ca678); }
.wl-palette-btn.cat-light { background: linear-gradient(135deg, #f59f00, #f08c00); }
.wl-palette-btn.cat-touch { background: linear-gradient(135deg, #e67700, #d9480f); }
.wl-palette-btn.cat-distance { background: linear-gradient(135deg, #be4bdb, #ae3ec9); }
.wl-palette-btn.cat-default { background: linear-gradient(135deg, #868e96, #495057); }

/* ── Block Stack ── one rule = one stack of blocks ── */
.wl-block-stack {
  position: relative;
  margin-bottom: 18px;
  padding-left: 6px;
}
.wl-block-stack.wl-rule-running {
  filter: drop-shadow(0 0 6px rgba(245,159,0,0.55));
}

/* Generic block base */
.wl-block {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px;
  margin-bottom: 0;
  color: #fff;
  font-family: var(--cb-font-display);
  font-size: 0.92em;
  font-weight: 600;
  border-radius: 6px;
  box-shadow: 0 2px 0 rgba(0,0,0,0.10);
  line-height: 1.3;
}
.wl-block + .wl-block { margin-top: 2px; }
.wl-block .blk-label { white-space: nowrap; }
.wl-block .blk-pill,
.wl-block select,
.wl-block input[type="number"] {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.95);
  color: #1a1a2e;
  border: none;
  border-radius: 999px;
  padding: 3px 10px;
  font-family: var(--cb-font-body);
  font-size: 0.92em;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  min-height: 22px;
}
.wl-block input[type="number"] {
  width: 60px;
  padding: 3px 8px;
  text-align: center;
}
.wl-block .blk-color-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.15);
  display: inline-block;
  vertical-align: middle;
}

/* Hat block (Event) — yellow, rounded top */
.wl-block.blk-hat {
  background: linear-gradient(135deg, #ffbf00, #f59f00);
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
  padding-top: 12px;
}

/* Control block (orange) — wraps If/Then with a "mouth" */
.wl-block-c {
  background: linear-gradient(135deg, #ff8c1a, #f76707);
  border-radius: 6px;
  padding: 8px;
  color: #fff;
  font-family: var(--cb-font-display);
  font-weight: 600;
}
.wl-block-c .ctrl-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 4px 6px;
}
.wl-block-c .ctrl-mouth {
  background: rgba(0,0,0,0.10);
  border-radius: 6px;
  margin: 4px 6px;
  padding: 6px;
  min-height: 30px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wl-block-c .ctrl-then-label {
  font-size: 0.85em;
  opacity: 0.85;
  padding: 4px 6px 0;
}

/* Sensing/condition block (cyan, hexagon look) */
.wl-block.blk-sense {
  background: linear-gradient(135deg, #5cb1d6, #3aa9c9);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.88em;
}
.wl-block.blk-sense.cat-temp { background: linear-gradient(135deg, #ff6b6b, #fa5252); }
.wl-block.blk-sense.cat-rain { background: linear-gradient(135deg, #339af0, #228be6); }
.wl-block.blk-sense.cat-wind { background: linear-gradient(135deg, #06d6a0, #0ca678); }
.wl-block.blk-sense.cat-light { background: linear-gradient(135deg, #f59f00, #f08c00); }
.wl-block.blk-sense.cat-touch { background: linear-gradient(135deg, #e67700, #d9480f); }
.wl-block.blk-sense.cat-distance { background: linear-gradient(135deg, #be4bdb, #ae3ec9); }

/* Action block (purple) */
.wl-block.blk-action {
  background: linear-gradient(135deg, #9966ff, #7c3aed);
  font-size: 0.9em;
}
.wl-block.blk-action.act-motor { background: linear-gradient(135deg, #4c6ef5, #364fc7); }
.wl-block.blk-action.act-master { background: linear-gradient(135deg, #f06292, #e91e63); }
.wl-block.blk-action.act-led { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #1a1a2e; }
.wl-block.blk-action.act-led .blk-pill { color: #1a1a2e; }
.wl-block.blk-action.act-sound { background: linear-gradient(135deg, #06b6d4, #0891b2); }

/* Action stack (purple wrapper for actions when in a control mouth) */
.wl-action-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Delete button on the rule stack */
.wl-block-stack .wl-rule-delete-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid #e03131;
  color: #e03131;
  font-weight: 700;
  cursor: pointer;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.10);
}
.wl-block-stack .wl-rule-delete-btn:hover { background: #e03131; color: #fff; }

/* "Test" mini button on each rule */
.wl-block-stack .wl-rule-test-btn {
  margin-top: 6px;
  padding: 5px 14px;
  background: #fff;
  border: 1.5px solid var(--cb-color-border);
  border-radius: 999px;
  font-size: 0.85em;
  color: var(--cb-color-text2);
  cursor: pointer;
  font-family: var(--cb-font-display);
  font-weight: 600;
}
.wl-block-stack .wl-rule-test-btn:hover { border-color: var(--cb-color-primary); color: var(--cb-color-primary); }

/* Wide container for desktop coding view (overrides wl-container 800px cap) */
.wl-container-wide {
  max-width: 1480px !important;
  padding: 0 12px;
}

/* 2-column desktop layout: blocks workspace | live simulation panel */
.wl-coding-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
  margin-top: 4px;
}
.wl-coding-col-blocks { min-width: 0; }
.wl-coding-col-sim    { min-width: 0; position: sticky; top: 80px; }
@media (max-width: 1100px) {
  .wl-coding-layout { grid-template-columns: 1fr; }
  .wl-coding-col-sim { position: static; }
}

/* Blockly workspace container */
.wl-blockly-workspace {
  width: 100%;
  height: 700px;
  border: 1.5px solid var(--cb-color-border);
  border-radius: 12px;
  overflow: hidden;
  background: #f8f9fa;
}
@media (max-width: 1100px) {
  .wl-blockly-workspace { height: 560px; }
}

/* ── Live Simulation panel ── */
.wl-sim-panel {
  background: #fff;
  border: 1.5px solid var(--cb-color-border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
[data-dark="true"] .wl-sim-panel { background: #0f172a; border-color: #1e293b; }

.wl-sim-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.wl-sim-title {
  font-family: var(--cb-font-display);
  font-size: 1.05em;
  font-weight: 800;
  color: var(--cb-color-text);
  line-height: 1.1;
}
[data-dark="true"] .wl-sim-title { color: #f1f5f9; }
.wl-sim-station {
  font-family: var(--cb-font-display);
  margin-bottom: 12px;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}
/* Primary span: city + date — bold black, draws the eye first. */
.wl-sim-station .wl-sim-station-main {
  font-size: 0.95em;
  font-weight: 700;
  color: var(--cb-color-text);
}
[data-dark="true"] .wl-sim-station .wl-sim-station-main { color: #f1f5f9; }
/* Secondary span: day progress sits inline to the right of the date,
   smaller and muted so the date is unmistakably the primary info. */
.wl-sim-station .wl-sim-station-progress {
  font-size: 0.82em;
  font-weight: 500;
  color: var(--cb-color-text2);
}
[data-dark="true"] .wl-sim-station .wl-sim-station-progress { color: #94a3b8; }
/* Initial empty/loading state ("먼저 데이터를 가져오세요"): plain string,
   no inner divs — keep readable. */
.wl-sim-station:not(:has(.wl-sim-station-main)) {
  display: block;
  font-size: 0.92em;
  color: var(--cb-color-text2);
  font-weight: 500;
}
/* "오늘의 날씨" wrapper: city/date caption + 5 stat tiles together. Light
   panel background visually unifies the date with its data so the student
   reads them as one block instead of an isolated label. */
.wl-sim-data-card {
  background: #f8fafc;
  border: 1.5px solid var(--cb-color-border);
  border-radius: 14px;
  padding: 14px;
}
[data-dark="true"] .wl-sim-data-card {
  background: #0f172a;
  border-color: #1e293b;
}
.wl-sim-data-card .wl-sim-stats { margin: 0; }

/* ── Click-to-run action block glow ──
   Applied to a workspace block's <g> while runSingleBlock executes. The
   drop-shadow filter is a soft yellow ring that fades on transition; it's
   purely visual feedback so the student sees "yes, my click did something".
   Removed automatically when execution completes. */
.wl-click-run > .blocklyPath {
  filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.85))
          drop-shadow(0 0 12px rgba(245, 158, 11, 0.45));
  transition: filter 0.15s ease;
}
[data-dark="true"] .wl-click-run > .blocklyPath {
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.95))
          drop-shadow(0 0 12px rgba(251, 191, 36, 0.55));
}

/* ── BLE connection log ──
   Rendered at the bottom of the BLE panel body (below the block cards and
   above the footer's "disconnect all" button). Compact, scrollable, with
   color-coded lines by kind (info / progress / success / error). */
.cb-ble-log {
  margin-top: 12px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid var(--cb-color-border);
  border-radius: 8px;
}
[data-dark="true"] .cb-ble-log {
  background: #0f172a;
  border-color: #1e293b;
}
.cb-ble-log-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--cb-color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.cb-ble-log-list {
  max-height: 160px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.4;
}
.cb-ble-log-line {
  padding: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cb-ble-log-time {
  color: var(--cb-color-text-muted);
  margin-right: 4px;
}
.cb-ble-log-progress .cb-ble-log-msg { color: #6b7280; }
.cb-ble-log-success  .cb-ble-log-msg { color: #16a34a; font-weight: 600; }
.cb-ble-log-error    .cb-ble-log-msg { color: #dc2626; font-weight: 600; }
.cb-ble-log-info     .cb-ble-log-msg { color: var(--cb-color-text); }
[data-dark="true"] .cb-ble-log-progress .cb-ble-log-msg { color: #94a3b8; }
[data-dark="true"] .cb-ble-log-success  .cb-ble-log-msg { color: #4ade80; }
[data-dark="true"] .cb-ble-log-error    .cb-ble-log-msg { color: #f87171; }

/* ── Master color preview dot ──
   Used in "마지막 동작" (simLastAction) and any other place where a CSS
   color value needs to be shown inline. 12px circle, subtle border for
   contrast on both light/dark backgrounds and for the white case. */
.wl-sim-color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.2);
  vertical-align: -2px;
  margin: 0 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
[data-dark="true"] .wl-sim-color-dot {
  border-color: rgba(255,255,255,0.3);
}

/* ── Compare-mode N-column card layout ──
   Activated when student's code references 2+ series-aware blocks. Each
   column shows one series's 5-stat block, side-by-side.
   - 2 cols: half-and-half on desktop
   - 3 cols: thirds, becomes 2-col grid on narrower screens
   - 4 cols: quarters, allowed to scroll horizontally on mobile so the
     student's choice of "compare 4 years" is honored rather than
     squashed (per user decision: option 2 = show all). */
.wl-sim-cmp-cols {
  display: grid;
  gap: 8px;
  /* The parent .wl-sim-stats is itself a 3-column grid (designed for the
     5 single-mode stat tiles). Without this rule, .wl-sim-cmp-cols only
     occupies 1 of those 3 columns and looks shoved to the left. Span all
     columns so the compare grid uses the full card width. */
  grid-column: 1 / -1;
}
.wl-sim-cmp-cols[data-cols="2"] { grid-template-columns: 1fr 1fr; }
.wl-sim-cmp-cols[data-cols="3"] { grid-template-columns: 1fr 1fr 1fr; }
.wl-sim-cmp-cols[data-cols="4"] { grid-template-columns: 1fr 1fr 1fr 1fr; }
.wl-sim-cmp-col {
  background: #ffffff;
  border: 1px solid var(--cb-color-border);
  border-radius: 10px;
  padding: 8px;
  min-width: 0;          /* allow text-truncate inside */
}
[data-dark="true"] .wl-sim-cmp-col {
  background: #1e293b;
  border-color: #334155;
}
.wl-sim-cmp-col-head {
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--cb-color-border);
  text-align: center;
}
[data-dark="true"] .wl-sim-cmp-col-head { border-bottom-color: #334155; }
.wl-sim-cmp-col-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--cb-color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wl-sim-cmp-col-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* Override the default single-card .wl-sim-stat horizontal layout for compare
   columns: inside a narrow column we need label on top, value below, both
   centered. Without this override the label gets squeezed and wraps to one
   character per line ("최\n고\n기\n온"). */
.wl-sim-cmp-col-stats .wl-sim-stat {
  display: block;
  padding: 6px 4px;
  border-radius: 6px;
  text-align: center;
  background: transparent;
}
.wl-sim-cmp-col-stats .wl-sim-stat-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 0;
}
.wl-sim-cmp-col-stats .wl-sim-stat-icon { opacity: 0.85; }
.wl-sim-cmp-col-stats .wl-sim-stat-lbl {
  font-size: 11px;
  color: var(--cb-color-text-muted);
  white-space: nowrap;
}
.wl-sim-cmp-col-stats .wl-sim-stat-val {
  font-size: 15px;
  font-weight: 700;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* Narrow viewport: allow horizontal scroll when 3+ columns get cramped */
@media (max-width: 680px) {
  .wl-sim-cmp-cols[data-cols="3"],
  .wl-sim-cmp-cols[data-cols="4"] {
    grid-template-columns: repeat(var(--cmp-cols, 2), minmax(140px, 1fr));
    overflow-x: auto;
  }
}
/* Multi-series compare modes stack cards vertically inside this container.
   Single mode has just one card, so the gap rule is a no-op there. */
.wl-sim-data-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* Extra series cards are visually equal to the primary so students don't
   read them as "secondary" — each series is its own peer. The is-extra
   class is a hook for any future emphasis tweaks without changing layout. */
.wl-sim-data-card.is-extra {
  /* same look as primary; class kept as a structural marker */
}

/* ── Compare-mode mini-table ─────────────────────────────────────────
   Replaces the stacked-cards layout in year/city compare modes. Designed
   for a quick glance: rows = series + diff, columns = 5 weather metrics.
   The "is-focused" class on a column comes from WLBlocks.usedSeriesDataKeys()
   — it marks the data the student's code actually reads, so the column
   pops visually without hiding the others. */
.wl-sim-cmp {
  background: #f8fafc;
  border: 1.5px solid var(--cb-color-border);
  border-radius: 14px;
  padding: 12px;
}
[data-dark="true"] .wl-sim-cmp {
  background: #0f172a;
  border-color: #1e293b;
}
.wl-sim-cmp-cap {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  padding: 0 4px;
}
.wl-sim-cmp-cap-date {
  font-weight: 700;
  font-size: 13px;
  color: var(--cb-color-text);
}
.wl-sim-cmp-cap-prog {
  font-size: 11px;
  color: var(--cb-color-text-muted);
}
.wl-sim-cmp-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}
.wl-sim-cmp-tbl th,
.wl-sim-cmp-tbl td {
  padding: 6px 4px;
  text-align: center;
  border-bottom: 1px solid var(--cb-color-border);
}
[data-dark="true"] .wl-sim-cmp-tbl th,
[data-dark="true"] .wl-sim-cmp-tbl td {
  border-bottom-color: #1e293b;
}
.wl-sim-cmp-tbl thead th {
  font-weight: 600;
  color: var(--cb-color-text-muted);
  font-size: 11px;
  white-space: nowrap;
}
.wl-sim-cmp-h-icon {
  display: inline-flex;
  vertical-align: middle;
  margin-right: 2px;
  opacity: 0.85;
}
.wl-sim-cmp-h-lbl {
  vertical-align: middle;
}
.wl-sim-cmp-focus-star {
  display: inline-block;
  margin-left: 3px;
  color: #f59e0b;
  font-size: 10px;
  vertical-align: middle;
}
/* Series row: name on the left (truncate if long), values centered */
.wl-sim-cmp-c-series {
  text-align: left !important;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--cb-color-text);
  max-width: 0;       /* let truncation kick in */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 8px !important;
}
.wl-sim-cmp-c-data {
  font-weight: 600;
  color: var(--cb-color-text);
  font-variant-numeric: tabular-nums;  /* keep columns aligned across rows */
}
/* Diff row: visually distinct (lighter weight, smaller label, color-coded values) */
.wl-sim-cmp-row-diff th,
.wl-sim-cmp-row-diff td {
  border-bottom: none;
  border-top: 2px solid var(--cb-color-border);
  padding-top: 8px;
}
[data-dark="true"] .wl-sim-cmp-row-diff th,
[data-dark="true"] .wl-sim-cmp-row-diff td {
  border-top-color: #1e293b;
}
.wl-sim-cmp-c-diff {
  text-align: left !important;
  font-size: 11px;
  font-weight: 600;
  color: var(--cb-color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-right: 8px !important;
}
.wl-sim-cmp-c-diff-val {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--cb-color-text-muted);
}
.wl-sim-cmp-c-diff-val.is-up   { color: #dc2626; }   /* increase → red (hotter/more) */
.wl-sim-cmp-c-diff-val.is-down { color: #2563eb; }   /* decrease → blue (cooler/less) */
[data-dark="true"] .wl-sim-cmp-c-diff-val.is-up   { color: #f87171; }
[data-dark="true"] .wl-sim-cmp-c-diff-val.is-down { color: #60a5fa; }
/* Focused column — the data the user's code references. Subtle vertical band
   so it reads as "this is what your code looks at" without screaming. */
.wl-sim-cmp-h-data.is-focused,
.wl-sim-cmp-c-data.is-focused,
.wl-sim-cmp-c-diff-val.is-focused {
  background: rgba(245, 158, 11, 0.08);
}
[data-dark="true"] .wl-sim-cmp-h-data.is-focused,
[data-dark="true"] .wl-sim-cmp-c-data.is-focused,
[data-dark="true"] .wl-sim-cmp-c-diff-val.is-focused {
  background: rgba(245, 158, 11, 0.15);
}
.wl-sim-cmp-h-data.is-focused {
  color: #b45309;
}
[data-dark="true"] .wl-sim-cmp-h-data.is-focused {
  color: #fbbf24;
}
.wl-sim-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.wl-sim-toolbar select {
  padding: 5px 10px;
  border: 1px solid var(--cb-color-border);
  border-radius: 8px;
  font-size: 0.85em;
  background: #fff;
  cursor: pointer;
  font-family: var(--cb-font-display);
  font-weight: 600;
}
[data-dark="true"] .wl-sim-toolbar select { background: #1e293b; color: #e2e8f0; border-color: #334155; }

/* BLE connection row inside Live Simulation panel */
.wl-sim-ble {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 10px;
  transition: background .2s, border-color .2s;
}
[data-dark="true"] .wl-sim-ble { background: rgba(245,158,11,0.10); border-color: rgba(245,158,11,0.30); }
.wl-sim-ble.partial   { background: #dbeafe; border-color: #bfdbfe; }
[data-dark="true"] .wl-sim-ble.partial { background: rgba(59,130,246,0.10); border-color: rgba(59,130,246,0.30); }
.wl-sim-ble.connected { background: #d1fae5; border-color: #a7f3d0; }
[data-dark="true"] .wl-sim-ble.connected { background: rgba(34,197,94,0.10); border-color: rgba(34,197,94,0.30); }
.wl-sim-ble-icon {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: #fbbf24;
  color: #fff;
  flex-shrink: 0;
}
.wl-sim-ble.partial   .wl-sim-ble-icon { background: #3b82f6; }
.wl-sim-ble.connected .wl-sim-ble-icon { background: #10b981; }
.wl-sim-ble-text { flex: 1; min-width: 0; }
.wl-sim-ble-status {
  font-family: var(--cb-font-display);
  font-size: 0.86em;
  font-weight: 700;
  color: #92400e;
}
.wl-sim-ble.partial   .wl-sim-ble-status { color: #1e40af; }
.wl-sim-ble.connected .wl-sim-ble-status { color: #065f46; }
[data-dark="true"] .wl-sim-ble-status,
[data-dark="true"] .wl-sim-ble.partial .wl-sim-ble-status,
[data-dark="true"] .wl-sim-ble.connected .wl-sim-ble-status { color: #f1f5f9; }
.wl-sim-ble-hint {
  font-size: 0.74em;
  color: var(--cb-color-text2);
  margin-top: 1px;
}
.wl-sim-ble-btn {
  padding: 6px 12px;
  background: #fff;
  border: 1.5px solid #d97706;
  color: #d97706;
  border-radius: 8px;
  font-family: var(--cb-font-display);
  font-weight: 700;
  font-size: 0.82em;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.wl-sim-ble.partial   .wl-sim-ble-btn { border-color: #2563eb; color: #2563eb; }
.wl-sim-ble.connected .wl-sim-ble-btn { border-color: #059669; color: #059669; }
.wl-sim-ble-btn:hover { transform: translateY(-1px); }

/* Weather stat cards — 5 metrics matching the block library
 * Layout: 3 columns × 2 rows (last row: 2 cards spanning).
 */
.wl-sim-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.wl-sim-stat {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 10px;
}
[data-dark="true"] .wl-sim-stat { background: #1e293b; border-color: #334155; }
.wl-sim-stat-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
}
.wl-sim-stat-icon {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px;
  background: var(--cb-color-primary-light);
  color: var(--cb-color-primary);
  flex-shrink: 0;
}
.wl-sim-stat.stat-tmax .wl-sim-stat-icon { background: #ffe3e3; color: #c92a2a; }
.wl-sim-stat.stat-tmin .wl-sim-stat-icon { background: #dbeafe; color: #1d4ed8; }
.wl-sim-stat.stat-tavg .wl-sim-stat-icon { background: #fff3bf; color: #b45309; }
.wl-sim-stat.stat-rain .wl-sim-stat-icon { background: #d0ebff; color: #1864ab; }
.wl-sim-stat.stat-wind .wl-sim-stat-icon { background: #d3f9d8; color: #06803a; }
.wl-sim-stat-lbl {
  font-size: 0.66em;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--cb-color-text2);
}
.wl-sim-stat-val {
  font-family: var(--cb-font-display);
  font-size: 1.15em;
  font-weight: 800;
  color: var(--cb-color-text);
  line-height: 1.05;
}
[data-dark="true"] .wl-sim-stat-val { color: #f1f5f9; }
.wl-sim-stat.stat-tmax .wl-sim-stat-val { color: #c92a2a; }
.wl-sim-stat.stat-tmin .wl-sim-stat-val { color: #1d4ed8; }
.wl-sim-stat.stat-tavg .wl-sim-stat-val { color: #b45309; }
.wl-sim-stat.stat-rain .wl-sim-stat-val { color: #1864ab; }
.wl-sim-stat.stat-wind .wl-sim-stat-val { color: #06803a; }

/* Robot status card */
.wl-sim-robot-card {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  border-radius: 14px;
  padding: 14px;
  color: #fff;
}
.wl-sim-robot-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.wl-sim-robot-title {
  font-family: var(--cb-font-display);
  font-weight: 700;
  font-size: 0.92em;
}
.wl-sim-robot-sub {
  font-size: 0.78em;
  opacity: 0.7;
  margin-top: 2px;
}
.wl-sim-robot-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: rgba(34,197,94,0.20);
  color: #4ade80;
  border-radius: 999px;
  font-size: 0.78em;
  font-weight: 700;
}
.wl-sim-robot-badge .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.wl-sim-robot-badge.busy { background: rgba(245,158,11,0.20); color: #fbbf24; }
.wl-sim-robot-badge.busy .dot { animation: wlPulse 1s infinite; }
@keyframes wlPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.wl-sim-robot-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 0;
}
.wl-sim-robot-circle {
  width: 116px; height: 116px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(96,165,250,0.45);
  display: inline-flex; align-items: center; justify-content: center;
  position: relative;
}
.wl-sim-robot-circle .wl-sim-robot {
  width: 70px; height: 70px;
  border-radius: 50%;
  background: rgba(96,165,250,0.18);
  display: inline-flex; align-items: center; justify-content: center;
  color: #93c5fd;
  transition: background .2s, color .2s;
}
.wl-sim-robot-circle .wl-sim-robot.active { background: rgba(74,222,128,0.20); color: #4ade80; }
@keyframes wlSimSpin     { to { transform: rotate(360deg); } }
@keyframes wlSimSpinBack { to { transform: rotate(-360deg); } }
.wl-sim-robot-circle .wl-sim-robot.spin-fwd  { animation: wlSimSpin     1.5s linear infinite; }
.wl-sim-robot-circle .wl-sim-robot.spin-back { animation: wlSimSpinBack 1.5s linear infinite; }

/* Sound wave — concentric pulsing rings while a buzzer note is playing. */
.wl-sim-sound-wave {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid transparent; pointer-events: none; opacity: 0;
}
.wl-sim-sound-wave.playing { animation: wlSimWave 0.9s ease-out infinite; }
.wl-sim-sound-wave--2.playing { animation-delay: 0.45s; }
@keyframes wlSimWave {
  0%   { transform: scale(0.95); border-color: rgba(96,165,250,0.7); opacity: 0.9; }
  100% { transform: scale(1.55); border-color: rgba(96,165,250,0);   opacity: 0; }
}

/* LED face badge — pops up at top-right when dotmatrix expression triggers. */
.wl-sim-face-badge {
  position: absolute; top: -6px; right: -10px;
  min-width: 30px; height: 24px; padding: 0 9px;
  border-radius: 12px;
  background: #fab005; color: #1a1a1a;
  font-size: 10.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(250,176,5,0.55);
  opacity: 0; transform: scale(0.4);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  white-space: nowrap;
}
.wl-sim-face-badge.show {
  opacity: 1; transform: scale(1);
  animation: wlSimFacePop 1.4s ease-out;
}
@keyframes wlSimFacePop {
  0%   { transform: scale(0.4); }
  20%  { transform: scale(1.18); }
  40%  { transform: scale(1); }
  100% { transform: scale(1); }
}

.wl-sim-robot-stage .wl-leds-row { display: flex; gap: 8px; }
.wl-sim-robot-stage .wl-sim-led {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.20);
  transition: background .15s, box-shadow .15s, border-color .15s;
}
/* Master-block colors — match the master_color block exactly. */
.wl-sim-robot-stage .wl-sim-led.red    { background: #ff4757; border-color: #ff4757; box-shadow: 0 0 12px rgba(255,71,87,0.7); }
.wl-sim-robot-stage .wl-sim-led.orange { background: #ffa94d; border-color: #ffa94d; box-shadow: 0 0 12px rgba(255,169,77,0.7); }
.wl-sim-robot-stage .wl-sim-led.yellow { background: #ffd43b; border-color: #ffd43b; box-shadow: 0 0 12px rgba(255,212,59,0.7); }
.wl-sim-robot-stage .wl-sim-led.green  { background: #06d6a0; border-color: #06d6a0; box-shadow: 0 0 12px rgba(6,214,160,0.7); }
.wl-sim-robot-stage .wl-sim-led.cyan   { background: #66d9ef; border-color: #66d9ef; box-shadow: 0 0 12px rgba(102,217,239,0.7); }
.wl-sim-robot-stage .wl-sim-led.blue   { background: #339af0; border-color: #339af0; box-shadow: 0 0 12px rgba(51,154,240,0.7); }
.wl-sim-robot-stage .wl-sim-led.purple { background: #b197fc; border-color: #b197fc; box-shadow: 0 0 12px rgba(177,151,252,0.7); }
.wl-sim-robot-stage .wl-sim-led.pink   { background: #ff85c0; border-color: #ff85c0; box-shadow: 0 0 12px rgba(255,133,192,0.7); }
.wl-sim-robot-stage .wl-sim-led.white  { background: #f1f3f5; border-color: #f1f3f5; box-shadow: 0 0 12px rgba(255,255,255,0.6); }

.wl-sim-robot-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.wl-sim-mini {
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 8px 10px;
}
.wl-sim-mini .lbl {
  font-size: 0.66em;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.65;
}
.wl-sim-mini .val {
  font-family: var(--cb-font-display);
  font-weight: 700;
  font-size: 0.92em;
  margin-top: 3px;
}

/* History list */
.wl-sim-history-head {
  font-family: var(--cb-font-display);
  font-size: 0.85em;
  font-weight: 700;
  color: var(--cb-color-text2);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.wl-sim-history .wl-log-box {
  max-height: 180px;
  overflow-y: auto;
}

/* ── Toolbox — simplified library look (icon + uppercase label) ── */
.wl-blockly-workspace .blocklyToolboxDiv {
  background: #ffffff;
  border-right: 1px solid #eef0f2;
  padding: 0;
  min-width: 168px;
  width: 168px;
}
[data-dark="true"] .wl-blockly-workspace .blocklyToolboxDiv {
  background: #0f172a;
  border-right-color: #1e293b;
}
.wl-toolbox-header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid #f1f5f9;
}
[data-dark="true"] .wl-toolbox-header { border-bottom-color: #1e293b; }
.wl-toolbox-header .wl-tlb-title {
  font-family: var(--cb-font-display);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #0f172a;
}
[data-dark="true"] .wl-toolbox-header .wl-tlb-title { color: #f1f5f9; }
.wl-toolbox-header .wl-tlb-version {
  font-size: 9px;
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: 0.10em;
  margin-top: 2px;
}

/* Tree row layout: icon + label, no Blockly stripe */
.wl-blockly-workspace .blocklyTreeRow {
  display: flex !important;
  align-items: center !important;
  padding: 9px 14px !important;
  margin: 4px 6px !important;
  border-radius: 8px !important;
  height: auto !important;
  line-height: 1 !important;
  border: 0 !important;
  background: transparent !important;
  cursor: pointer;
  transition: background .15s;
}
.wl-blockly-workspace .blocklyTreeRow:hover {
  background: #f8fafc !important;
}
[data-dark="true"] .wl-blockly-workspace .blocklyTreeRow:hover {
  background: #1e293b !important;
}
.wl-blockly-workspace .blocklyTreeSelected {
  background: #eff6ff !important;
  position: relative;
}
[data-dark="true"] .wl-blockly-workspace .blocklyTreeSelected {
  background: rgba(59,130,246,0.12) !important;
}
.wl-blockly-workspace .blocklyTreeSelected::after {
  content: '';
  position: absolute;
  right: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: #3b82f6;
  border-radius: 2px;
}
.wl-blockly-workspace .blocklyTreeIcon { display: none !important; }
.wl-blockly-workspace .blocklyTreeLabel {
  font-family: var(--cb-font-display) !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.05em !important;
  color: #475569 !important;
  padding-left: 10px !important;
  text-transform: uppercase;
}
[data-dark="true"] .wl-blockly-workspace .blocklyTreeLabel { color: #cbd5e1 !important; }
.wl-blockly-workspace .blocklyTreeSelected .blocklyTreeLabel { color: #2563eb !important; }
.wl-cat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  flex-shrink: 0;
}
[data-dark="true"] .wl-cat-icon { color: #94a3b8; }
.wl-blockly-workspace .blocklyTreeSelected .wl-cat-icon { color: #2563eb; }

/* Run / Stop buttons (Scratch green flag style) */
.wl-block-run, .wl-block-stop {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: none;
  border-radius: 999px;
  font-family: var(--cb-font-display);
  font-weight: 700;
  font-size: 0.92em;
  cursor: pointer;
  transition: transform .12s, filter .15s;
}
.wl-block-run  { background: linear-gradient(135deg, #06d6a0, #15aabf); color: #fff; }
.wl-block-stop { background: linear-gradient(135deg, #ff6b6b, #fa5252); color: #fff; }
.wl-block-run:hover, .wl-block-stop:hover { transform: translateY(-1px); filter: brightness(1.05); }
.wl-block-run .wl-icon, .wl-block-stop .wl-icon { width: 14px; height: 14px; }

/* ── Playback state visualization ──
 * When a simulation is running we mark <body> with `wl-playing`. The Start
 * button fades to "disabled" feel (so it's clear another click won't help)
 * and the Stop button gains a soft pulse plus a leading dot to draw the
 * eye. Once the engine fires 'done' or stop() runs, the class is removed
 * and both buttons return to their idle state. */
body.wl-playing .wl-block-run {
  opacity: 0.45;
  cursor: default;
  filter: grayscale(0.4);
  pointer-events: none;
}
body.wl-playing .wl-block-stop {
  animation: wlStopPulse 1.2s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(250, 82, 82, 0.55);
}
body.wl-playing .wl-block-stop::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  margin-right: 2px;
  animation: wlStopBlink 1s ease-in-out infinite;
}
@keyframes wlStopPulse {
  0%   { box-shadow: 0 0 0 0   rgba(250, 82, 82, 0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(250, 82, 82, 0);   }
  100% { box-shadow: 0 0 0 0   rgba(250, 82, 82, 0);   }
}
@keyframes wlStopBlink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}
[data-dark="true"] .wl-blockly-workspace { background: #1e293b; border-color: #334155; }

/* Tighter on narrow screens */
@media (max-width: 720px) {
  .wl-blockly-workspace { height: 460px; }
}

/* Empty state for the rules canvas */
.wl-rules-empty {
  text-align: center;
  padding: 32px 20px;
  color: var(--cb-color-text2);
  background: var(--cb-color-bg);
  border: 1.5px dashed var(--cb-color-border);
  border-radius: 14px;
  font-size: 0.95em;
}

/* ──────────────────────────────────────────────
 * Worksheet (탐구 노트) — interactive 6-tab activity
 * ────────────────────────────────────────────── */
.wl-worksheet-card {
  padding: 0;
  overflow: hidden;
  position: relative;
}
.wl-worksheet-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(180deg, transparent 0, transparent 31px, #f1f5f9 31px, #f1f5f9 32px);
  background-size: 100% 32px;
  pointer-events: none;
  opacity: 0.35;
}
[data-dark="true"] .wl-worksheet-card::before {
  background-image: linear-gradient(180deg, transparent 0, transparent 31px, #1e293b 31px, #1e293b 32px);
}
.wl-worksheet-card > * { position: relative; z-index: 1; }

.wl-ws-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1.5px solid var(--cb-color-border);
  background: linear-gradient(180deg, #fff, #f8fafc);
  padding: 6px 6px 0;
}
[data-dark="true"] .wl-ws-tabs { background: linear-gradient(180deg, #0f172a, #1e293b); }
.wl-ws-tab {
  flex: 1;
  min-width: 70px;
  padding: 12px 10px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  font-family: var(--cb-font-display);
  font-size: 0.95em;
  font-weight: 700;
  color: var(--cb-color-text2);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.wl-ws-tab:hover { color: var(--cb-color-text); background: rgba(0,0,0,0.03); }
.wl-ws-tab.active {
  color: var(--cb-color-text);
  border-bottom-color: var(--cb-color-primary);
}
[data-dark="true"] .wl-ws-tab.active { color: #f1f5f9; }
/* Per-category accent under active tab */
.wl-ws-tab[data-cat="economy"].active     { border-bottom-color: #f59f00; }
.wl-ws-tab[data-cat="tourism"].active     { border-bottom-color: #d6336c; }
.wl-ws-tab[data-cat="agriculture"].active { border-bottom-color: #06803a; }
.wl-ws-tab[data-cat="environment"].active { border-bottom-color: #06b6d4; }
.wl-ws-tab[data-cat="transport"].active   { border-bottom-color: #1d4ed8; }
.wl-ws-tab[data-cat="industry"].active    { border-bottom-color: #7c3aed; }

.wl-ws-panes {
  padding: 18px;
}
.wl-ws-pane { display: none; }
.wl-ws-pane.active { display: block; }

/* Examples box — color-coded per category */
.wl-ws-examples {
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: #fff9db;
  border-left: 4px solid #f59f00;
}
.wl-ws-examples.cat-tourism     { background: #ffe0e9; border-left-color: #d6336c; }
.wl-ws-examples.cat-agriculture { background: #d3f9d8; border-left-color: #06803a; }
.wl-ws-examples.cat-environment { background: #c5f6fa; border-left-color: #06b6d4; }
.wl-ws-examples.cat-transport   { background: #dbeafe; border-left-color: #1d4ed8; }
.wl-ws-examples.cat-industry    { background: #ede9fe; border-left-color: #7c3aed; }
.wl-ws-ex-title {
  font-family: var(--cb-font-display);
  font-weight: 700;
  font-size: 0.92em;
  margin-bottom: 6px;
  color: var(--cb-color-text);
}
.wl-ws-examples ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.wl-ws-examples li {
  padding: 5px 0;
  font-size: 0.92em;
  line-height: 1.55;
  color: var(--cb-color-text);
}
.wl-ws-examples li::before {
  content: '·';
  margin-right: 8px;
  font-weight: 700;
  color: var(--cb-color-text2);
}

/* Worksheet textarea — feels like writing on paper */
.wl-ws-label {
  display: block;
  font-family: var(--cb-font-display);
  font-weight: 700;
  font-size: 0.92em;
  color: var(--cb-color-text);
  margin: 6px 0 6px;
}
[data-dark="true"] .wl-ws-label { color: #f1f5f9; }
.wl-ws-textarea {
  width: 100%;
  min-height: 140px;
  padding: 12px 14px;
  border: 1.5px solid var(--cb-color-border);
  border-radius: 10px;
  font-family: var(--cb-font-body);
  font-size: 0.95em;
  line-height: 1.7;
  resize: vertical;
  background-image: linear-gradient(180deg, transparent 0, transparent 31px, #e0e7ef 31px, #e0e7ef 32px);
  background-size: 100% 32px;
  background-attachment: local;
  outline: none;
  color: var(--cb-color-text);
}
[data-dark="true"] .wl-ws-textarea {
  background-color: #1e293b;
  background-image: linear-gradient(180deg, transparent 0, transparent 31px, #334155 31px, #334155 32px);
  color: #e2e8f0;
  border-color: #334155;
}
.wl-ws-textarea:focus { border-color: var(--cb-color-primary); }

.wl-ws-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 18px 16px;
  font-size: 0.82em;
  color: var(--cb-color-text2);
}
.wl-ws-save-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #d1fae5;
  color: #065f46;
  font-weight: 700;
}
.wl-ws-save-status.saving { background: #fef3c7; color: #92400e; }
[data-dark="true"] .wl-ws-save-status { background: rgba(34,197,94,0.15); color: #6ee7b7; }
.wl-ws-tip {
  flex: 1;
  text-align: right;
  min-width: 180px;
}

/* ──────────────────────────────────────────────
 * Print — only the generated report preview should print.
 * The Report tab's input form, missions checklist, preview-card
 * buttons, etc. would otherwise appear above the generated report.
 * ────────────────────────────────────────────── */
@media print {
  /* Hide everything by default */
  body * { visibility: hidden !important; }
  /* Reveal only the report preview and its descendants */
  #reportPreview, #reportPreview * { visibility: visible !important; }
  /* Lift the preview to the top-left of the page so it isn't pushed down */
  #reportPreview {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }
  /* Avoid clipping by ancestor containers */
  html, body, .cb-app, .cb-body-wrap, .cb-main, #wl-tab-report,
  #wl-tab-report .wl-container { overflow: visible !important; height: auto !important; }
}

/* Mission boxes inside Report tab — flatter than original */
#missionsSection .wl-mission-box {
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1.5px solid var(--cb-color-border);
  background: linear-gradient(135deg, #fff9db, #ffec99);
}
#missionsSection .wl-mission-box:last-child { margin-bottom: 0; }
#missionsSection .wl-mission-box h3 {
  font-family: var(--cb-font-display);
  font-size: 1em;
  font-weight: 700;
  margin: 0 0 8px;
}
#missionsSection .wl-mission-list { list-style: none; padding: 0; margin: 0; }
#missionsSection .wl-mission-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0;
  font-size: 0.92em;
}
#missionsSection .wl-mission-list .check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  background: #fff;
  border: 1.5px solid var(--cb-color-border);
  cursor: pointer;
  flex-shrink: 0;
  font-weight: 700;
  color: #06803a;
  transition: background .15s, border-color .15s;
}
#missionsSection .wl-mission-list .check.done {
  background: #06d6a0;
  border-color: #06d6a0;
  color: #fff;
}
#missionsSection .wl-mission-list .check.done::before { content: '✓'; }

/* Chart card title with icon */
.wl-card-title .title-icon {
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--cb-color-primary-light);
  color: var(--cb-color-primary);
  margin-right: 6px;
}
.wl-card-title .title-icon .wl-icon { width: 16px; height: 16px; }
.wl-card-title.chart-title-temp .title-icon { background: #ffe3e3; color: #c92a2a; }
.wl-card-title.chart-title-rain .title-icon { background: #d0ebff; color: #1864ab; }
.wl-card-title.chart-title-wind .title-icon { background: #d3f9d8; color: #06803a; }

/* ══════════════════════════════════════════════════════════
 *  Integrated Guide Modal (4 mini-tabs)
 *  Triggered by ❓ button in the global app header.
 * ══════════════════════════════════════════════════════════ */
.wl-help-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.wl-help-overlay.open { opacity: 1; pointer-events: auto; }
.wl-help-overlay[hidden] { display: none; }
.wl-help-card {
  width: 100%; max-width: 880px;
  max-height: 92vh; overflow: hidden;
  background: var(--cb-color-surface, #fff);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(15,23,42,0.20);
  display: flex; flex-direction: column;
  animation: wlHelpPop .3s cubic-bezier(.2,.7,.3,1);
}
@keyframes wlHelpPop {
  from { transform: translateY(20px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
[data-dark="true"] .wl-help-card { background: #1e293b; color: #e2e8f0; }
[data-dark="true"] .wl-help-card,
[data-dark="true"] .wl-help-card * { color: #e2e8f0; }
[data-dark="true"] .wl-help-card .feat-sub,
[data-dark="true"] .wl-help-card p { color: #94a3b8; }

/* Head */
.wl-help-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid rgba(15,23,42,0.06);
}
.wl-help-head h2 {
  margin: 0; font-size: 18px; font-weight: 700;
  display: flex; gap: 8px; align-items: center;
}
.wl-help-emoji { font-size: 22px; }
.wl-help-close {
  width: 32px; height: 32px; border-radius: 8px;
  border: none; background: transparent; cursor: pointer;
  font-size: 16px; color: var(--cb-color-text2, #6b7280);
}
.wl-help-close:hover { background: rgba(15,23,42,0.06); }

/* Tabs */
.wl-help-tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid rgba(15,23,42,0.06);
  padding: 0 12px;
  background: #fafbfd;
}
[data-dark="true"] .wl-help-tabs { background: #0f172a; }
.wl-help-tab {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 10px;
  border: none; background: transparent; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--cb-color-text2, #6b7280);
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
}
.wl-help-tab:hover { color: var(--cb-color-text); background: rgba(15,23,42,0.03); }
.wl-help-tab.active {
  color: var(--cb-color-primary);
  border-bottom-color: var(--cb-color-primary);
  background: var(--cb-color-surface);
}
[data-dark="true"] .wl-help-tab.active { background: #1e293b; }
.wl-help-tab .tab-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(15,23,42,0.08); color: var(--cb-color-text2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.wl-help-tab.active .tab-num { background: var(--cb-color-primary); color: #fff; }

/* Body / panes */
.wl-help-body {
  flex: 1; overflow-y: auto;
  padding: 22px 24px 18px;
}
.wl-help-pane { display: none; flex-direction: column; gap: 16px; }
.wl-help-pane.active { display: flex; }
.wl-help-pane > p { margin: 0; font-size: 13.5px; color: var(--cb-color-text2); line-height: 1.6; }

.wl-help-section-title {
  font-size: 12.5px; font-weight: 700; color: var(--cb-color-text2);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin: 0 0 -2px;
}

/* 3-step flow */
.wl-help-steps {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.wl-help-steps li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 14px 12px; border-radius: 12px;
  background: linear-gradient(180deg, #f1f5fb 0%, #e8eef9 100%);
  border: 1px solid rgba(74, 127, 224, 0.10);
}
[data-dark="true"] .wl-help-steps li {
  background: #0f172a; border-color: rgba(148,163,184,0.12);
}
.wl-help-steps .step-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--cb-color-primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.wl-help-steps strong { font-size: 13.5px; display: block; margin-bottom: 3px; }
.wl-help-steps p { font-size: 12px; color: var(--cb-color-text2); margin: 0; line-height: 1.45; }

/* Card grid */
.wl-help-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.wl-help-block-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 11px 12px; border-radius: 10px;
  background: #f8fafc; border: 1px solid rgba(15,23,42,0.05);
}
[data-dark="true"] .wl-help-block-card {
  background: #0f172a; border-color: rgba(148,163,184,0.10);
}
.wl-help-block-card .block-pill {
  display: inline-flex; align-self: flex-start;
  padding: 5px 12px; border-radius: 14px;
  background: #5cb3ff; color: #fff;
  font-size: 12px; font-weight: 700;
  box-shadow: 0 2px 4px rgba(92,179,255,0.30);
}
.wl-help-block-card p { font-size: 12.5px; color: var(--cb-color-text2); margin: 0; line-height: 1.5; }
.wl-help-block-card code {
  font-size: 11.5px; font-family: 'Menlo', monospace;
  color: var(--cb-color-primary); background: #eef3fc;
  padding: 1px 5px; border-radius: 4px;
}

/* Mode comparison (Tab 1) */
.wl-mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.wl-mode-card {
  padding: 12px; border-radius: 12px;
  background: #f8fafc; border: 1px solid rgba(15,23,42,0.06);
  display: flex; flex-direction: column; gap: 6px;
}
[data-dark="true"] .wl-mode-card {
  background: #0f172a; border-color: rgba(148,163,184,0.10);
}
.wl-mode-card.is-recommend { background: #f0f9ff; border-color: #74c0fc; }
[data-dark="true"] .wl-mode-card.is-recommend { background: #082f49; border-color: #38bdf8; }
.wl-mode-card .mode-tag {
  align-self: flex-start;
  padding: 3px 9px; border-radius: 10px;
  font-size: 11px; font-weight: 700;
  background: rgba(15,23,42,0.06); color: var(--cb-color-text2);
}
.wl-mode-card.is-recommend .mode-tag { background: var(--cb-color-primary); color: #fff; }
.wl-mode-card h4 { margin: 0; font-size: 14px; font-weight: 700; }
.wl-mode-card p { margin: 0; font-size: 12px; color: var(--cb-color-text2); line-height: 1.5; }
.wl-mode-card .mode-use { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.wl-mode-card .use-chip {
  font-size: 11px; padding: 2px 8px; border-radius: 8px;
  background: #fff; border: 1px solid rgba(15,23,42,0.06); color: var(--cb-color-text2);
}
.wl-mode-card .use-chip.is-on  { background: #dcfce7; border-color: #4ade80; color: #166534; }
.wl-mode-card .use-chip.is-off { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; text-decoration: line-through; }

/* Feature list */
.wl-feature-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.wl-feature-list li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; border-radius: 10px;
  background: #f8fafc; border: 1px solid rgba(15,23,42,0.06);
  font-size: 13px; line-height: 1.5;
}
[data-dark="true"] .wl-feature-list li {
  background: #0f172a; border-color: rgba(148,163,184,0.10);
}
.wl-feature-list .feat-icon {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--cb-color-primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.wl-feature-list strong { display: block; margin-bottom: 2px; font-size: 13.5px; }
.wl-feature-list .feat-sub { color: var(--cb-color-text2); font-size: 12px; }

/* Example cards (Tab 3) */
.wl-help-example-card {
  border: 1px solid rgba(15,23,42,0.06); border-radius: 12px;
  background: #fff; overflow: hidden;
}
[data-dark="true"] .wl-help-example-card { background: #1e293b; border-color: rgba(148,163,184,0.10); }
.wl-help-example-card .ex-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 13px;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid rgba(15,23,42,0.06);
}
[data-dark="true"] .wl-help-example-card .ex-head {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  border-bottom-color: rgba(148,163,184,0.10);
}
.ex-emoji { font-size: 16px; }
.ex-title { font-weight: 700; font-size: 13.5px; }
.ex-tag {
  margin-left: auto;
  font-size: 11px; color: var(--cb-color-text2);
  background: #fff; border: 1px solid rgba(15,23,42,0.06);
  padding: 2px 8px; border-radius: 10px;
}
[data-dark="true"] .ex-tag { background: #0f172a; border-color: rgba(148,163,184,0.10); }
.wl-help-example {
  background: #fafbfd;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
[data-dark="true"] .wl-help-example { background: #0b1220; }
.wl-help-example .block-mini {
  font-size: 12.5px; font-weight: 700; color: #fff;
  padding: 7px 12px; border-radius: 6px;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wl-help-example .block-mini.indent-1 { margin-left: 18px; }
.wl-help-example .block-mini.indent-2 { margin-left: 36px; }
.wl-help-example .block-event   { background: #ffaa00; }
.wl-help-example .block-control { background: #ff8c1a; }
.wl-help-example .block-motor   { background: #22c55e; }
.wl-help-example .block-master  { background: #c084fc; }
.wl-help-example .block-led     { background: #4ade80; color: #1a1a1a; }
.wl-help-example .block-sound   { background: #f472b6; }
.wl-help-example .block-inline {
  display: inline-flex; padding: 2px 8px; border-radius: 10px;
  background: rgba(255,255,255,0.30); font-size: 11.5px;
}
.wl-help-example .color-swatch {
  display: inline-block; width: 14px; height: 14px;
  border-radius: 50%; vertical-align: middle;
  border: 1.5px solid rgba(255,255,255,0.6);
}

/* Yes / No coding-pattern cards (Pane 3 model section) */
.wl-help-yesno { gap: 12px; }
.wl-help-yesno-card {
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid; background: #fff;
  display: flex; flex-direction: column; gap: 6px;
}
.wl-help-yesno-card .yesno-head {
  font-size: 13px; font-weight: 700;
}
.wl-help-yesno-card ul {
  margin: 0; padding-left: 18px;
  display: flex; flex-direction: column; gap: 4px;
}
.wl-help-yesno-card li { font-size: 12.5px; line-height: 1.5; color: var(--cb-color-text2); }
.wl-help-yesno-card li strong { color: var(--cb-color-text); }
.wl-help-yesno-card.is-yes { background: #f0fdf4; border-color: #86efac; }
.wl-help-yesno-card.is-yes .yesno-head { color: #166534; }
/* `is-no` used to mean "❌ patterns that don't work" (red). Now that the
   async model makes most of those patterns valid, this slot holds neutral
   tips ("💡 알아두면 좋아요"), so we shift the palette to soft amber so the
   card reads as informational rather than a warning. */
.wl-help-yesno-card.is-no  { background: #fffbeb; border-color: #fcd34d; }
.wl-help-yesno-card.is-no  .yesno-head { color: #92400e; }
[data-dark="true"] .wl-help-yesno-card.is-yes { background: #052e16; border-color: #166534; }
[data-dark="true"] .wl-help-yesno-card.is-yes .yesno-head { color: #86efac; }
[data-dark="true"] .wl-help-yesno-card.is-no  { background: #422006; border-color: #b45309; }
[data-dark="true"] .wl-help-yesno-card.is-no  .yesno-head { color: #fcd34d; }

/* Tip */
.wl-help-tip {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 10px;
  background: #fff8db; border: 1px solid #ffe066;
  font-size: 13px; line-height: 1.5;
}
.wl-help-tip--info { background: #e7f5ff; border-color: #74c0fc; }
.wl-help-tip em { font-style: normal; font-weight: 700; color: var(--cb-color-primary); }
[data-dark="true"] .wl-help-tip { background: #4d3e0e; border-color: #8a6914; color: #fde68a; }
[data-dark="true"] .wl-help-tip--info { background: #082f49; border-color: #38bdf8; color: #bae6fd; }
.tip-emoji { font-size: 16px; flex-shrink: 0; }

/* Foot */
.wl-help-foot {
  padding: 14px 24px 20px; border-top: 1px solid rgba(15,23,42,0.06);
  display: flex; justify-content: space-between; align-items: center;
}
.wl-help-progress { font-size: 12px; color: var(--cb-color-text2); }
.wl-help-progress strong { color: var(--cb-color-primary); font-weight: 700; }
.wl-help-next {
  padding: 9px 22px; border: none; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  background: var(--cb-color-primary); color: #fff;
  transition: filter .15s, transform .15s;
}
.wl-help-next:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* Trigger button — header */
.wl-help-trigger {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border: none; background: transparent;
  border-radius: var(--cb-radius-sm, 8px);
  cursor: pointer; color: var(--cb-color-text2);
  transition: all 0.15s;
}
.wl-help-trigger:hover { background: rgba(15,23,42,0.06); color: var(--cb-color-primary); }

/* Banner link variant — for the "1단계로 가기" yellow banner */
.wl-ctx-help {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 8px;
  padding: 7px 12px;
  background: transparent; border: 1px solid rgba(15,23,42,0.10);
  border-radius: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--cb-color-text2);
  cursor: pointer;
  transition: all .15s;
}
.wl-ctx-help:hover { background: rgba(15,23,42,0.04); color: var(--cb-color-text); }

@media (max-width: 720px) {
  .wl-help-steps, .wl-help-grid, .wl-mode-grid { grid-template-columns: 1fr; }
  .wl-help-tab { font-size: 12px; padding: 10px 4px; }
  .wl-help-tab .tab-num { width: 20px; height: 20px; font-size: 11px; }
}
