:root {
  --bg:        #0f0f0f;
  --bg2:       #1a1a1a;
  --bg3:       #232323;
  --border:    #2e2e2e;
  --text:      #e0e0e0;
  --text2:     #888;
  --text3:     #555;
  --blue:      #3a7bd5;
  --blue-act:  #0d2444;
  --blue-text: #60b0f0;
  --radius:    6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  font-size: 13px;
}

/* ── HEADER ── */
header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.header-brand h1  { font-size: 15px; font-weight: 600; }
.header-brand p   { font-size: 11px; color: var(--text2); margin-top: 2px; }
.header-actions   { display: flex; align-items: center; gap: 14px; }

.pro-link {
  font-size: 11px;
  font-weight: 600;
  color: #e8c040;
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid #4a3a08;
  border-radius: var(--radius);
  background: #4a3a0822;
  transition: background 0.15s;
}
.pro-link:hover { background: #4a3a0855; }

.save-status { font-size: 11px; color: var(--text3); }

/* ── MAIN ── */
main {
  padding: 20px 32px;
  max-width: 860px;
  margin: 0 auto;
}

/* ── ROW / TABS ── */
.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.row-label { font-size: 10px; color: var(--text3); width: 56px; flex-shrink: 0; }
.tabs-group { display: flex; gap: 4px; flex-wrap: wrap; }

button.tab {
  padding: 4px 11px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  color: var(--text2);
  transition: all 0.1s;
  white-space: nowrap;
  position: relative;
}
button.tab:hover          { border-color: var(--text3); color: var(--text); }
button.tab.pos-active     { background: var(--text); color: var(--bg); border-color: var(--text); }
button.tab.sit-active     { background: var(--blue-act); color: var(--blue-text); border-color: var(--blue); }

/* badge ✓ on filled situations */
button.tab .badge {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 14px;
  height: 14px;
  background: #1a6b1a;
  color: #7ecc7e;
  border-radius: 50%;
  font-size: 8px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.antes-wrap { display: flex; align-items: center; gap: 6px; margin-left: 4px; }
.antes-wrap label { font-size: 11px; color: var(--text2); cursor: pointer; user-select: none; }
input[type=checkbox] { cursor: pointer; accent-color: var(--blue); }

/* ── CONTEXT BOX ── */
.ctx-box {
  font-size: 10px;
  color: var(--text2);
  margin-bottom: 10px;
  padding: 6px 10px;
  background: var(--bg2);
  border-radius: 5px;
  border-left: 2px solid var(--blue);
  line-height: 1.6;
}

/* ── LEGEND / STAT ── */
.top-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.legend  { display: flex; gap: 5px; flex-wrap: wrap; }

.leg {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1.5px solid transparent;
  font-size: 11px;
  color: var(--text2);
  transition: all 0.1s;
}
.leg.sel { border-color: var(--text); color: var(--text); }
.dot { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }

.stat { margin-left: auto; font-size: 11px; color: var(--text2); }
.stat strong { color: var(--text); }

/* ── GRID ── */
.grid-wrap {
  overflow-x: auto;
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
}
.grid {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 2px;
  width: 100%;
  max-width: 780px;
}

.hdr {
  font-size: 9px;
  font-weight: 600;
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 26px;
}

.cell {
  height: 0;
  padding-bottom: 100%;
  position: relative;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter 0.08s;
}
.cell:hover { filter: brightness(1.2); border-color: rgba(255,255,255,0.22); }

.cell-lbl {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  pointer-events: none;
}

/* ── TOOLBAR ── */
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }

button.btn {
  padding: 5px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  color: var(--text2);
  transition: all 0.1s;
}
button.btn:hover            { background: var(--bg2); color: var(--text); border-color: var(--text3); }
button.btn.btn-accent       { border-color: var(--blue); color: var(--blue-text); }
button.btn.btn-accent:hover { background: var(--blue-act); }
button.btn.btn-primary      { background: var(--blue-act); color: var(--blue-text); border-color: var(--blue); font-weight: 600; }
button.btn.btn-primary:hover { background: #1a3d6a; border-color: #5090e0; color: #90c8ff; }
button.btn.btn-dev          { border-color: #4a3a08; color: #e8c040; font-size: 10px; }
button.btn.btn-dev:hover    { background: #4a3a0822; }

/* ── EXPORT AREA ── */
.export-area {
  display: none;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.export-area h3  { font-size: 12px; color: var(--text); margin-bottom: 8px; }
.export-area pre {
  font-size: 10px;
  color: var(--text2);
  white-space: pre-wrap;
  line-height: 1.6;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg3);
  padding: 8px;
  border-radius: 4px;
}

/* ── NOTES ── */
.notes-section { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 4px; }
.notes-section h2 { font-size: 13px; color: var(--text); margin-bottom: 10px; }
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.note-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}
.note-card label { font-size: 10px; color: var(--text3); display: block; margin-bottom: 4px; }
.note-card textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 11px;
  padding: 6px;
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
  line-height: 1.5;
}
.note-card textarea:focus { outline: none; border-color: var(--text3); }

/* ── HELP BUTTON ── */
.btn-help {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text3);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  flex-shrink: 0;
}
.btn-help:hover { border-color: var(--text3); color: var(--text); }

/* ── LEGEND KEY HINTS ── */
.leg-key {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 9px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
  color: var(--text3);
  margin-left: 4px;
}

/* ── SIDEBAR ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(0,0,0,0.45);
}
.sidebar-overlay.open { display: block; }

.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 284px;
  height: 100vh;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  z-index: 100;
  transform: translateX(100%);
  transition: transform 0.18s ease;
  overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }

.sidebar-inner { padding: 18px 16px 32px; }

.sidebar-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 13px;
  padding: 3px 7px;
  border-radius: 4px;
  line-height: 1;
}
.sidebar-close:hover { color: var(--text); background: var(--bg3); }

.sb-heading {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text3);
  margin: 22px 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
.sb-heading:first-of-type { margin-top: 4px; }

.sb-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0;
  font-size: 11px;
  color: var(--text2);
  border-bottom: 1px solid var(--bg3);
}
.sb-row:last-of-type { border-bottom: none; }

.sb-key {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--text);
  flex-shrink: 0;
  min-width: 28px;
  text-align: center;
}

.sb-term {
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
  width: 52px;
}
.sb-def {
  color: var(--text2);
  flex: 1;
}

.sb-p {
  font-size: 11px;
  color: var(--text2);
  line-height: 1.65;
  margin-bottom: 8px;
}
.sb-p:last-child { margin-bottom: 0; }

.sb-clog {
  font-size: 11px;
  color: var(--text2);
  padding: 4px 0;
  border-bottom: 1px solid var(--bg3);
}
.sb-clog:last-child { border-bottom: none; }
.sb-clog strong { color: var(--text); }

/* ── HAMBURGER ── */
.btn-hamburger {
  width: 30px;
  height: 26px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  flex-shrink: 0;
}
.btn-hamburger:hover { border-color: var(--text3); color: var(--text); }

/* ── GRID AREA (left panel + grid) ── */
.grid-area {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.grid-col { flex: 1; min-width: 0; }

/* pos-panel: hidden by default, shown on large screens */
.pos-panel { display: none; }

@media (min-width: 1120px) {
  main          { max-width: 1080px; }
  .pos-panel {
    display: block;
    width: 190px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
  }
  /* hide ctx-box when pos-panel is visible */
  .ctx-box { display: none; }
  /* align tab rows with the grid column (panel 190px + gap 24px = 214px) */
  section.row { margin-left: calc(190px + 24px); }
}

/* ── POS PANEL — résumé situation ── */
.pp-pos-name {
  font-size: 38px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 3px;
  letter-spacing: -.01em;
}
.pp-pos-desc {
  font-size: 10px;
  color: var(--text3);
  margin-bottom: 20px;
  line-height: 1.4;
}
.pp-sit-row {
  margin-bottom: 12px;
}
.pp-sit-label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text3);
  margin-bottom: 4px;
}
.pp-sit-stat {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.pp-sit-combos {
  font-size: 11px;
  font-weight: 400;
  color: var(--text3);
}
.pp-ctx {
  font-size: 10px;
  color: var(--text2);
  line-height: 1.65;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ── SIDEBAR PRO SECTION ── */
.sb-pro-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--bg3);
}
.sb-pro-item:last-of-type { border-bottom: none; }

.sb-pro-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 6px;
}

.sb-pro-btn {
  display: block;
  padding: 7px 12px;
  border-radius: 5px;
  border: 1px solid var(--blue);
  background: var(--blue-act);
  color: var(--blue-text);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: background 0.1s;
}
.sb-pro-btn:hover { background: #1a3d6a; }

.sb-locked-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text3);
  font-size: 11px;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}
.sb-locked-btn:hover { background: var(--bg3); }

.sb-pro-badge {
  font-size: 9px;
  font-weight: 700;
  color: #e8c040;
  background: #4a3a0822;
  border: 1px solid #4a3a08;
  border-radius: 3px;
  padding: 1px 5px;
  flex-shrink: 0;
}
.sb-coming-soon {
  font-size: 9px;
  color: var(--text3);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  flex-shrink: 0;
}

/* Preset selector */
.sb-preset-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
}
.sb-preset-select {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 11px;
  padding: 4px 6px;
  min-width: 0;
}
.sb-preset-load {
  padding: 5px 10px;
  border-radius: 4px;
  border: 1px solid var(--blue);
  background: var(--blue-act);
  color: var(--blue-text);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s;
}
.sb-preset-load:hover { background: #1a3d6a; }
.sb-preset-desc {
  font-size: 10px;
  color: var(--text3);
  margin: 0 0 4px;
  line-height: 1.4;
}
.sb-warning {
  font-size: 10px;
  color: #c88030;
  line-height: 1.4;
  margin: 0;
}
.sb-inline-export {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #c88030;
  background: transparent;
  color: #c88030;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.1s;
}
.sb-inline-export:hover { background: #4a3a0820; }

/* Import/Export JSON */
.sb-json-row {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}
.sb-json-btn {
  flex: 1;
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 10px;
  cursor: pointer;
  transition: all 0.1s;
}
.sb-json-btn:hover { background: var(--bg3); color: var(--text); }

/* Unlock link at bottom of Pro section */
.sb-pro-unlock-wrap { margin-top: 14px; text-align: center; }
.sb-pro-unlock {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #e8c040;
  text-decoration: none;
  padding: 6px 16px;
  border: 1px solid #4a3a08;
  border-radius: 5px;
  background: #4a3a0822;
  transition: background 0.15s;
}
.sb-pro-unlock:hover { background: #4a3a0855; }

/* ── POSITION NOTES ── */
.pos-notes-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 4px;
  margin-bottom: 0;
}
.pos-notes-section h2 { font-size: 13px; color: var(--text); margin-bottom: 8px; }
.pos-note-ta {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 11px;
  padding: 8px 10px;
  resize: vertical;
  min-height: 68px;
  font-family: inherit;
  line-height: 1.5;
}
.pos-note-ta:focus { outline: none; border-color: var(--text3); }

/* ── MOBILE ── */
@media (max-width: 600px) {
  header        { padding: 12px 14px; }
  main          { padding: 12px 14px; }
  .cell-lbl     { font-size: 7px; }
  .stat         { margin-left: 0; width: 100%; }
  .sidebar      { width: 88vw; }
}
