/* Plane Packer — style.css */

:root {
  --bg: #0b1220;
  --panel: #111a2c;
  --panel2: #182440;
  --line: #223352;
  --line-soft: #1b2943;
  --text: #e8eefc;
  --muted: #93a4c3;
  --accent: #38bdf8;
  --accent-ink: #04283f;
  --ok: #34d399;
  --ok-ink: #053024;
  --warn: #fbbf24;
  --danger: #fb7185;
  --radius: 16px;
  --chip: rgba(255, 255, 255, 0.06);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #eef3fb;
    --panel: #ffffff;
    --panel2: #e6eefa;
    --line: #d4e0f2;
    --line-soft: #e4ecf8;
    --text: #0d1b38;
    --muted: #5c6f94;
    --accent: #0284c7;
    --accent-ink: #ffffff;
    --ok: #059669;
    --ok-ink: #ffffff;
    --warn: #b45309;
    --chip: rgba(13, 27, 56, 0.05);
    --shadow: 0 8px 24px rgba(30, 50, 90, 0.12);
  }
}

:root[data-theme="light"] {
  --bg: #eef3fb;
  --panel: #ffffff;
  --panel2: #e6eefa;
  --line: #d4e0f2;
  --line-soft: #e4ecf8;
  --text: #0d1b38;
  --muted: #5c6f94;
  --accent: #0284c7;
  --accent-ink: #ffffff;
  --ok: #059669;
  --ok-ink: #ffffff;
  --warn: #b45309;
  --chip: rgba(13, 27, 56, 0.05);
  --shadow: 0 8px 24px rgba(30, 50, 90, 0.12);
}

:root[data-theme="dark"] {
  --bg: #0b1220;
  --panel: #111a2c;
  --panel2: #182440;
  --line: #223352;
  --line-soft: #1b2943;
  --text: #e8eefc;
  --muted: #93a4c3;
  --accent: #38bdf8;
  --accent-ink: #04283f;
  --ok: #34d399;
  --ok-ink: #053024;
  --warn: #fbbf24;
  --chip: rgba(255, 255, 255, 0.06);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.25s ease, color 0.25s ease;
}

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 18px 16px 48px;
}

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.head-left { flex: 1; min-width: 0; }

h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.plane {
  width: 26px;
  height: 26px;
  fill: var(--accent);
  flex: none;
}

.tag {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 600;
}

.ring-wrap {
  position: relative;
  width: 88px;
  height: 88px;
  flex: none;
}

.ring { width: 100%; height: 100%; display: block; }

.ring-bg {
  fill: none;
  stroke: var(--line);
  stroke-width: 9;
}

.ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 9;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 0.45s ease;
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#pnum {
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.1;
}

#ppct {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
}

/* ---------- Panels & controls ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.intro p { margin: 0; font-size: 0.9rem; color: var(--text); }
.intro strong { color: var(--accent); }

.ctl { margin-bottom: 14px; }
.ctl:last-child { margin-bottom: 0; }

.ctl-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 7px;
}

.ctl-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.4;
}

.seg {
  display: flex;
  gap: 4px;
  background: var(--panel2);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 4px;
}

.seg button {
  flex: 1;
  min-height: 44px;
  padding: 0 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.seg button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

.seg button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  cursor: pointer;
}

.switch-text { flex: 1; min-width: 0; }
.switch-text .ctl-label { margin-bottom: 2px; }
.switch-text .ctl-hint { margin-top: 0; }

.switch { position: relative; display: inline-block; flex: none; width: 52px; height: 30px; }

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.track {
  position: absolute;
  inset: 0;
  background: var(--panel2);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  transition: background 0.2s ease, border-color 0.2s ease;
  pointer-events: none;
}

.track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s ease, background 0.2s ease;
}

.switch input:checked + .track {
  background: var(--ok);
  border-color: var(--ok);
}

.switch input:checked + .track::after {
  transform: translateX(22px);
  background: #fff;
}

.switch input:focus-visible + .track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Status + tabs ---------- */
.statusline {
  font-size: 0.95rem;
  font-weight: 800;
  margin: 4px 2px 10px;
  color: var(--text);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.tabs button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tabs button[aria-pressed="true"] {
  background: var(--panel2);
  border-color: var(--accent);
  color: var(--text);
}

.tabs button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.badge {
  background: var(--chip);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
}

.tabs button[aria-pressed="true"] .badge { color: var(--accent); }

/* ---------- Item list ---------- */
.list { margin-bottom: 16px; }

.cat { margin-bottom: 18px; }

.cat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px;
  padding: 0 4px;
}

.cat-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: var(--cat, var(--accent));
  flex: none;
}

.cat-count {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--chip);
  border-radius: 999px;
  padding: 2px 10px;
}

.items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.item {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.item:active { transform: scale(0.99); }

.item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.item[aria-checked="true"] {
  background: var(--panel);
  border-color: rgba(52, 211, 153, 0.45);
}

.box {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  border: 2px solid var(--muted);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.item[aria-checked="true"] .box {
  background: var(--ok);
  border-color: var(--ok);
}

.tick {
  width: 18px;
  height: 18px;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.item[aria-checked="true"] .tick { opacity: 1; }

.tick.broken { visibility: hidden; }

.item-ico {
  flex: none;
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 9px;
  background: var(--chip);
  padding: 3px;
  margin-top: 1px;
}

.item-ico.broken { visibility: hidden; }

.copy { flex: 1; min-width: 0; }

.name {
  display: block;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.3;
  transition: color 0.15s ease;
}

.item[aria-checked="true"] .name {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--muted);
  text-decoration-thickness: 1.5px;
}

.why {
  display: block;
  margin-top: 3px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--muted);
}

.empty {
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 22px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 18px;
}

.btn, .icon-btn {
  min-height: 48px;
  border-radius: 13px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn { padding: 0 14px; }

.btn.ghost {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--muted);
}

.btn.ghost:hover { border-color: var(--muted); }

.btn.primary {
  background: var(--accent);
  border: 1.5px solid var(--accent);
  color: var(--accent-ink);
}

.btn.primary:hover { filter: brightness(1.05); }

.icon-btn {
  width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1.5px solid var(--line);
  padding: 0;
}

.icon-btn img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  filter: invert(1) brightness(1.6); /* black icon -> visible on dark panels */
}

:root[data-theme="light"] .icon-btn img,
:root:not([data-theme]) body:not(.dark) .icon-btn img { filter: none; }

.icon-btn.off { opacity: 0.45; }

.btn:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Tips ---------- */
.tips h2 {
  font-size: 1rem;
  font-weight: 800;
  margin: 0 0 8px;
}

.tips details {
  border-top: 1px solid var(--line-soft);
  padding: 10px 0;
}

.tips details:first-of-type { border-top: 0; }

.tips summary {
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  padding: 4px 0;
  color: var(--text);
  list-style-position: outside;
}

.tips summary::-webkit-details-marker { color: var(--muted); }

.tips p {
  margin: 6px 0 4px;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.55;
}

/* ---------- Footer / toast ---------- */
footer p {
  font-size: 0.74rem;
  color: var(--muted);
  text-align: center;
  margin: 24px 8px 0;
}

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 0.84rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 10px 18px;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 40px);
  text-align: center;
  z-index: 50;
}

.toast[hidden] { display: none; }

/* ---------- Small screens ---------- */
@media (max-width: 380px) {
  .wrap { padding: 14px 12px 40px; }
  h1 { font-size: 1.2rem; }
  .ring-wrap { width: 78px; height: 78px; }
  .seg button { font-size: 0.76rem; }
  .item { padding: 10px; gap: 10px; }
  .why { font-size: 0.77rem; }
}
