/* ═══════════════════════════════════════════════════════════════
   Show Your Hand — MS Paint / Windows 95 theme
   ═══════════════════════════════════════════════════════════════ */

/* ─── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-radius: 0 !important;
}

:root {
  --win-gray:      #c0c0c0;
  --win-light:     #ffffff;
  --win-mid:       #dfdfdf;
  --win-shadow:    #808080;
  --win-dark:      #404040;
  --win-black:     #000000;
  --win-title:     #000080;
  --win-title-end: #1084d0;
  --win-text:      #000000;
  --win-teal:      #a0a0a0;
  --win-select:    #000080;
  --font-ui: 'MS Sans Serif', 'Tahoma', Arial, system-ui, sans-serif;
  --font-size: 11px;
}

html, body {
  height: 100%;
  background: var(--win-gray);
  color: var(--win-text);
  font-family: var(--font-ui);
  font-size: var(--font-size);
  line-height: 1.3;
  cursor: default;
  overflow: hidden;
}

/* ─── Win95 raised panel ─────────────────────────────────────────────── */
.raised {
  box-shadow:
    inset -1px -1px 0 var(--win-shadow),
    inset  1px  1px 0 var(--win-light),
    inset -2px -2px 0 var(--win-dark),
    inset  2px  2px 0 var(--win-mid);
}

.sunken {
  box-shadow:
    inset  1px  1px 0 var(--win-shadow),
    inset -1px -1px 0 var(--win-light),
    inset  2px  2px 0 var(--win-dark),
    inset -2px -2px 0 var(--win-mid);
}

/* ─── Landing dialog overlay ─────────────────────────────────────────── */
.win-dialog-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--win-teal);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.win-dialog-overlay.active { display: flex; }

.win-dialog {
  background: var(--win-gray);
  box-shadow:
    inset -1px -1px 0 var(--win-shadow),
    inset  1px  1px 0 var(--win-light),
    inset -2px -2px 0 var(--win-dark),
    inset  2px  2px 0 var(--win-mid),
    4px 4px 0 #000;
  min-width: 360px;
}

.win-dialog-body {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 20px;
}

.win-dialog-art {
  width: 64px;
  height: auto;
  flex-shrink: 0;
  mix-blend-mode: multiply;
}

.win-dialog-text p {
  margin-bottom: 6px;
  font-size: 11px;
  line-height: 1.6;
}

.win-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px 14px;
}

/* ─── Main window ────────────────────────────────────────────────────── */
#win-app.win-window {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  background: var(--win-gray);
}

/* ─── Title bar ──────────────────────────────────────────────────────── */
.win-titlebar {
  height: 22px;
  background: linear-gradient(to right, var(--win-title), var(--win-title-end));
  display: flex;
  align-items: center;
  padding: 0 2px 0 4px;
  gap: 4px;
  flex-shrink: 0;
  user-select: none;
}

.win-titlebar-icon {
  font-size: 12px;
  flex-shrink: 0;
}

.win-titlebar-text {
  flex: 1;
  font-size: 11px;
  font-weight: bold;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.win-titlebar-btns {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.win-tb-btn {
  width: 16px;
  height: 14px;
  background: var(--win-gray);
  border: none;
  font-size: 9px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset -1px -1px 0 var(--win-shadow),
    inset  1px  1px 0 var(--win-light);
  font-family: var(--font-ui);
}

.win-tb-btn:active {
  box-shadow:
    inset  1px  1px 0 var(--win-shadow),
    inset -1px -1px 0 var(--win-light);
}

/* ─── Menu bar ───────────────────────────────────────────────────────── */
.win-menubar {
  height: 20px;
  background: var(--win-gray);
  display: flex;
  align-items: center;
  padding: 0 2px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--win-shadow);
  gap: 0;
}

.win-menu-btn {
  height: 100%;
  padding: 0 8px;
  background: none;
  border: none;
  font-size: 11px;
  font-family: var(--font-ui);
  cursor: pointer;
  color: var(--win-text);
  white-space: nowrap;
}

.win-menu-btn:hover,
.win-menu-btn.active {
  background: var(--win-select);
  color: #fff;
}

.win-menu-btn u { text-decoration: underline; }

.win-menu-sep {
  flex: 1;
}

.win-menu-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 8px;
  font-size: 10px;
}

.progress-bar {
  width: 100px;
  height: 8px;
  box-shadow:
    inset  1px  1px 0 var(--win-shadow),
    inset -1px -1px 0 var(--win-light);
  background: var(--win-gray);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--win-title);
  transition: width 0.3s;
}

/* ─── Workspace ──────────────────────────────────────────────────────── */
.win-workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── Left toolbar panel ─────────────────────────────────────────────── */
.win-toolbar-panel {
  width: 62px;
  flex-shrink: 0;
  background: var(--win-gray);
  border-right: 1px solid var(--win-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 4px 4px;
  gap: 0;
  overflow: hidden;
}

.win-tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  width: 100%;
  margin-bottom: 4px;
}

.win-tool-btn {
  width: 26px;
  height: 26px;
  background: var(--win-gray);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-family: var(--font-ui);
  font-weight: bold;
  color: var(--win-text);
  box-shadow:
    inset -1px -1px 0 var(--win-shadow),
    inset  1px  1px 0 var(--win-light);
}

.win-tool-btn:hover {
  box-shadow:
    inset -1px -1px 0 var(--win-shadow),
    inset  1px  1px 0 var(--win-light),
    inset -2px -2px 0 var(--win-dark),
    inset  2px  2px 0 var(--win-mid);
}

.win-tool-btn:active,
.win-tool-btn.active {
  box-shadow:
    inset  1px  1px 0 var(--win-shadow),
    inset -1px -1px 0 var(--win-light),
    inset  2px  2px 0 var(--win-dark),
    inset -2px -2px 0 var(--win-mid);
}

.win-tool-btn svg { pointer-events: none; }

.win-tool-divider {
  width: 100%;
  height: 1px;
  background: var(--win-shadow);
  box-shadow: 0 1px 0 var(--win-light);
  margin: 4px 0;
  flex-shrink: 0;
}

.win-tool-label {
  font-size: 9px;
  color: var(--win-text);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  width: 100%;
  margin-bottom: 3px;
  padding-left: 1px;
}

/* Size presets */
.win-size-presets {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  margin-bottom: 4px;
}

.pen-size-pill {
  width: 100%;
  height: 18px;
  background: var(--win-gray);
  border: none;
  font-size: 9px;
  font-family: var(--font-ui);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--win-text);
  box-shadow:
    inset -1px -1px 0 var(--win-shadow),
    inset  1px  1px 0 var(--win-light);
}

.pen-size-pill:hover {
  background: var(--win-select);
  color: #fff;
}

.win-size-slider {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 2px;
}

.win-size-slider input[type=range] {
  width: 100%;
  accent-color: var(--win-title);
  height: 14px;
}

.win-size-slider span {
  font-size: 9px;
  color: var(--win-shadow);
}

/* Stroke counter */
#stroke-counter { margin-top: 2px; }
#stroke-count-label { font-size: 9px; word-break: break-all; }
#stroke-count-label.ok   { color: #008000; font-weight: bold; }
#stroke-count-label.warn { color: #800000; font-weight: bold; }

/* Toolbar nav buttons */
.win-toolbar-spacer { flex: 1; }

.win-toolbar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding-bottom: 4px;
}

.win-btn-full { width: 100%; font-size: 10px; padding: 3px 4px; }

/* ─── Win95 buttons (universal) ──────────────────────────────────────── */
.win-btn {
  background: var(--win-gray);
  border: none;
  font-family: var(--font-ui);
  font-size: 11px;
  padding: 4px 12px;
  cursor: pointer;
  color: var(--win-text);
  min-width: 72px;
  box-shadow:
    inset -1px -1px 0 var(--win-shadow),
    inset  1px  1px 0 var(--win-light),
    inset -2px -2px 0 var(--win-dark),
    inset  2px  2px 0 var(--win-mid);
  white-space: nowrap;
}

.win-btn:active {
  box-shadow:
    inset  1px  1px 0 var(--win-shadow),
    inset -1px -1px 0 var(--win-light),
    inset  2px  2px 0 var(--win-dark),
    inset -2px -2px 0 var(--win-mid);
  padding: 5px 11px 3px 13px;
}

.win-btn:disabled {
  color: var(--win-shadow);
  cursor: default;
}

.win-btn-default {
  box-shadow:
    0 0 0 2px var(--win-black),
    inset -1px -1px 0 var(--win-shadow),
    inset  1px  1px 0 var(--win-light),
    inset -2px -2px 0 var(--win-dark),
    inset  2px  2px 0 var(--win-mid);
}

.win-btn-ghost {
  color: var(--win-shadow);
  box-shadow:
    inset -1px -1px 0 var(--win-mid),
    inset  1px  1px 0 var(--win-mid);
}

/* ─── Content area ───────────────────────────────────────────────────── */
.win-content-area {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--win-gray);
}

.view { display: none; width: 100%; height: 100%; }
.view.active { display: flex; flex-direction: column; }

/* ─── DRAW VIEW ──────────────────────────────────────────────────────── */

/* Alphabet strip */
.win-alpha-strip {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 2px 4px;
  gap: 1px;
  background: var(--win-gray);
  border-bottom: 1px solid var(--win-shadow);
  flex-shrink: 0;
  scrollbar-width: none;
}

.win-alpha-strip::-webkit-scrollbar { display: none; }

.alpha-chip {
  flex-shrink: 0;
  height: 18px;
  min-width: 18px;
  padding: 0 3px;
  background: var(--win-gray);
  border: none;
  font-size: 10px;
  font-family: var(--font-ui);
  cursor: pointer;
  color: var(--win-text);
  box-shadow:
    inset -1px -1px 0 var(--win-shadow),
    inset  1px  1px 0 var(--win-light);
}

.alpha-chip:hover { background: var(--win-mid); }

.alpha-chip.active {
  background: var(--win-select);
  color: #fff;
  box-shadow:
    inset  1px  1px 0 var(--win-shadow),
    inset -1px -1px 0 var(--win-light);
}

.alpha-chip.has-data {
  background: #00aa00;
  color: #fff;
}

.alpha-chip.has-both {
  background: var(--win-title);
  color: #fff;
}

.alpha-chip.active.has-data,
.alpha-chip.active.has-both {
  box-shadow:
    inset  1px  1px 0 var(--win-shadow),
    inset -1px -1px 0 var(--win-light);
}

.strip-divider {
  flex-shrink: 0;
  width: 1px;
  height: 12px;
  background: var(--win-shadow);
  margin: 0 2px;
}

/* Preview strip */
.win-preview-strip {
  height: 48px;
  background: var(--win-gray);
  display: flex;
  align-items: center;
  padding: 0 8px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--win-shadow);
  position: relative;
}

.preview-label {
  font-size: 9px;
  color: var(--win-shadow);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  position: absolute;
  top: 4px;
  left: 8px;
}

#preview-strip-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Canvas outer (the gray area around the white canvas, like Paint) */
.win-canvas-outer {
  flex: 1;
  overflow: auto;
  background: var(--win-gray);
  padding: 8px;
  box-shadow: inset 1px 1px 0 var(--win-shadow);
}

.win-canvas-scroll {
  display: inline-block;
  box-shadow:
    inset  1px  1px 0 var(--win-shadow),
    inset -1px -1px 0 var(--win-light),
    inset  2px  2px 0 var(--win-dark),
    inset -2px -2px 0 var(--win-mid);
  background: #fff;
}

.canvas-wrap {
  position: relative;
  background: #fff;
  cursor: crosshair;
  width: 360px;
  height: 360px;
}

.canvas-ghost {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 200px;
  font-weight: bold;
  color: #e8e8e8;
  pointer-events: none;
  user-select: none;
  z-index: 0;
  line-height: 1;
  font-family: Arial, sans-serif;
}

#draw-canvas {
  position: relative;
  z-index: 1;
}

.canvas-inner-border {
  position: absolute;
  top: 12px; left: 12px; right: 12px; bottom: 12px;
  border: 1px dashed #d0d0d0;
  pointer-events: none;
  z-index: 2;
}

.master-overlay {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  z-index: 3;
  pointer-events: none;
  box-shadow:
    inset -1px -1px 0 var(--win-shadow),
    inset  1px  1px 0 var(--win-light);
}

.master-overlay.master-A { background: var(--win-gray); color: var(--win-text); }
.master-overlay.master-B { background: var(--win-title); color: #fff; }

/* ─── View inner (Compose + Font) ────────────────────────────────────── */
.win-view-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  height: 100%;
  overflow-y: auto;
}

/* ─── Win95 Group box ────────────────────────────────────────────────── */
.win-group-box {
  background: var(--win-gray);
  padding: 12px 10px 10px;
  position: relative;
  box-shadow:
    inset  1px  1px 0 var(--win-shadow),
    inset -1px -1px 0 var(--win-light);
  flex-shrink: 0;
}

.win-group-grow { flex: 1; display: flex; flex-direction: column; }

.win-group-label {
  position: absolute;
  top: -6px;
  left: 8px;
  background: var(--win-gray);
  padding: 0 4px;
  font-size: 10px;
  font-weight: bold;
  color: var(--win-text);
}

/* ─── Axis slider ────────────────────────────────────────────────────── */
.win-axis-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.axis-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--win-shadow);
}

.axis-val-display {
  font-weight: bold;
  color: var(--win-text);
  font-variant-numeric: tabular-nums;
}

.win-range {
  width: 100%;
  accent-color: var(--win-title);
}

/* ─── Compose output ─────────────────────────────────────────────────── */
.compose-output {
  flex: 1;
  min-height: 80px;
  background: #fff;
  box-shadow:
    inset  1px  1px 0 var(--win-shadow),
    inset -1px -1px 0 var(--win-light),
    inset  2px  2px 0 var(--win-dark);
  overflow: hidden;
  margin-bottom: 8px;
}

.compose-output canvas { display: block; max-width: 100%; }

.win-textarea {
  width: 100%;
  min-height: 48px;
  resize: vertical;
  font-family: var(--font-ui);
  font-size: 11px;
  padding: 4px 6px;
  background: #fff;
  border: none;
  outline: none;
  color: var(--win-text);
  box-shadow:
    inset  1px  1px 0 var(--win-shadow),
    inset -1px -1px 0 var(--win-light),
    inset  2px  2px 0 var(--win-dark);
}

/* ─── Font export form ───────────────────────────────────────────────── */
.win-form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.win-form-row-gap { margin-top: 12px; }

.win-label {
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
}

.win-input {
  flex: 1;
  height: 20px;
  padding: 0 4px;
  font-family: var(--font-ui);
  font-size: 11px;
  background: #fff;
  border: none;
  outline: none;
  color: var(--win-text);
  box-shadow:
    inset  1px  1px 0 var(--win-shadow),
    inset -1px -1px 0 var(--win-light),
    inset  2px  2px 0 var(--win-dark);
}

.export-status {
  font-size: 10px;
  color: var(--win-shadow);
  flex: 1;
}

.export-status.ok   { color: #008000; }
.export-status.warn { color: #800000; }

.win-code {
  background: #fff;
  padding: 8px;
  font-size: 10px;
  font-family: 'Courier New', monospace;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  margin: 8px 0;
  box-shadow:
    inset  1px  1px 0 var(--win-shadow),
    inset -1px -1px 0 var(--win-light);
  color: var(--win-text);
}

/* ─── Font grid ──────────────────────────────────────────────────────── */
.font-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 2px;
  background: var(--win-shadow);
  margin-top: 8px;
  flex: 1;
}

.font-tile {
  background: var(--win-gray);
  cursor: pointer;
  overflow: hidden;
}

.font-tile:hover { background: var(--win-mid); }

.font-tile-preview {
  height: 48px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #d0d0d0;
  font-family: Arial, sans-serif;
}

.font-tile.has-data .font-tile-preview { background: #fff; }
.font-tile.has-both .font-tile-preview { background: #eef; }

.font-tile-info {
  padding: 2px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--win-gray);
}

.tile-letter { font-size: 10px; font-weight: bold; }
.tile-masters { display: flex; gap: 2px; }

.master-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  font-size: 7px;
  font-weight: bold;
}

.dot-a     { background: #008000; color: #fff; }
.dot-b     { background: var(--win-title); color: #fff; }
.dot-empty { background: var(--win-mid); color: var(--win-shadow); }

/* ─── Status bar ─────────────────────────────────────────────────────── */
.win-statusbar {
  height: 20px;
  background: var(--win-gray);
  border-top: 1px solid var(--win-shadow);
  display: flex;
  align-items: center;
  padding: 0 4px;
  gap: 2px;
  flex-shrink: 0;
}

.win-status-pane {
  height: 14px;
  padding: 0 6px;
  font-size: 10px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  box-shadow:
    inset  1px  1px 0 var(--win-shadow),
    inset -1px -1px 0 var(--win-light);
}

.win-status-pane.progress-label {
  min-width: 60px;
  justify-content: center;
}

/* ─── Toast ──────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--win-gray);
  color: var(--win-text);
  font-size: 11px;
  font-family: var(--font-ui);
  padding: 8px 16px;
  opacity: 0;
  transition: all 0.15s;
  z-index: 9998;
  pointer-events: none;
  box-shadow:
    inset -1px -1px 0 var(--win-shadow),
    inset  1px  1px 0 var(--win-light),
    inset -2px -2px 0 var(--win-dark),
    inset  2px  2px 0 var(--win-mid),
    3px 3px 0 #000;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Keyboard hint ──────────────────────────────────────────────────── */
.kbd-hint {
  position: fixed;
  bottom: 26px;
  right: 8px;
  background: var(--win-gray);
  padding: 8px 10px;
  font-size: 10px;
  font-family: var(--font-ui);
  z-index: 800;
  line-height: 1.8;
  box-shadow:
    inset -1px -1px 0 var(--win-shadow),
    inset  1px  1px 0 var(--win-light);
}

.kbd-hint strong { font-weight: bold; }

kbd {
  display: inline-block;
  padding: 0 4px;
  font-family: var(--font-ui);
  font-size: 9px;
  background: var(--win-gray);
  box-shadow:
    inset -1px -1px 0 var(--win-shadow),
    inset  1px  1px 0 var(--win-light);
}

/* ─── Master toggle active states ────────────────────────────────────── */
.master-btn[data-master="B"].active {
  background: var(--win-title);
  color: #fff;
  box-shadow:
    inset  1px  1px 0 var(--win-shadow),
    inset -1px -1px 0 var(--win-light);
}

/* ─── Scrollbars (Win95 style approximation) ─────────────────────────── */
::-webkit-scrollbar { width: 16px; height: 16px; }
::-webkit-scrollbar-track { background: var(--win-gray); }
::-webkit-scrollbar-thumb {
  background: var(--win-gray);
  box-shadow:
    inset -1px -1px 0 var(--win-shadow),
    inset  1px  1px 0 var(--win-light);
}
::-webkit-scrollbar-button {
  background: var(--win-gray);
  box-shadow:
    inset -1px -1px 0 var(--win-shadow),
    inset  1px  1px 0 var(--win-light);
  height: 16px;
  width: 16px;
}
