/* ==========================================================
   ToyKit — Tactile Toy-Workshop Design System
   Warm craft-paper studio + crisp ink outlines + chunky 3D press buttons
   ========================================================== */

:root {
  /* Paper & Desk Surfaces */
  --bg-desk: #F4EFE4;
  --bg-desk-dot: #D8CEB8;
  --surface: #FFFDF8;
  --surface-alt: #F9F4E8;
  --surface-hover: #F3EAD6;

  /* Crisp Ink & Borders */
  --ink: #1E2430;
  --ink-soft: #4A5568;
  --ink-muted: #768092;
  --border: 2.5px solid #1E2430;
  --border-thin: 1.8px solid #1E2430;

  /* Playful Studio Toy Palette */
  --teal: #1597BB;
  --teal-light: #DDF4FA;
  --yellow: #FFD23F;
  --yellow-light: #FFF6CC;
  --orange: #FF7A1A;
  --orange-light: #FFE8D4;
  --coral: #F24B4B;
  --coral-light: #FFE0E0;
  --green: #1EB866;
  --green-dark: #148F4E;
  --green-light: #D9F9E6;
  --blue: #3B6EF5;
  --blue-light: #E2EBFF;
  --pink: #FF5D8F;

  /* Hard Tactile Shadows */
  --shadow-sm: 2px 2px 0 #1E2430;
  --shadow-md: 4px 4px 0 #1E2430;
  --shadow-lg: 6px 6px 0 #1E2430;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Typography */
  --font-main: 'Rubik', 'Heebo', 'Segoe UI', Arial, sans-serif;
}

/* Native CJK crisp UI stack for Simplified Chinese (zero multi-MB webfonts, 100% China-safe) */
html[lang="zh"] {
  --font-main: 'PingFang SC', 'HarmonyOS Sans SC', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
}
html[lang="zh"] body {
  line-height: 1.5;
}

/* Keep Latin brand wordmark crisp LTR even in Hebrew RTL */
.brand-text {
  direction: ltr;
  unicode-bidi: isolate;
}

.bidi-auto {
  unicode-bidi: isolate;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-main);
  color: var(--ink);
  background-color: var(--bg-desk);
  background-image: radial-gradient(var(--bg-desk-dot) 1.3px, transparent 1.3px);
  background-size: 20px 20px;
  overflow: hidden;
  user-select: none;
}

input, select, textarea, button {
  font-family: inherit;
  color: inherit;
}

input[type="text"], input[type="number"], textarea {
  user-select: text;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.45;
}

/* ========== CHUNKY TACTILE BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  min-height: 40px;
  font-size: 0.92rem;
  font-weight: 700;
  border: var(--border-thin);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.12s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-hover);
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 #1E2430;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-sm {
  min-height: 34px;
  padding: 5px 10px;
  font-size: 0.84rem;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background: var(--teal);
  color: #fff;
}
.btn-primary:hover { background: #1285A6; }

.btn-secondary {
  background: var(--blue-light);
  color: var(--ink);
}
.btn-secondary:hover { background: #CFE0FF; }

.btn-play {
  background: var(--green);
  color: #fff;
  border-width: 2.2px;
  box-shadow: 3px 3px 0 #1E2430;
}
.btn-play:hover { background: var(--green-dark); }

.btn-magic {
  background: var(--orange);
  color: #fff;
  border-width: 2.2px;
  box-shadow: 3px 3px 0 #1E2430;
}
.btn-magic:hover { background: #E96B0F; }

.btn-yellow {
  background: var(--yellow);
  color: var(--ink);
}
.btn-yellow:hover { background: #F5C428; }

.btn-danger {
  background: var(--coral);
  color: #fff;
}
.btn-danger:hover { background: #DB3B3B; }

.btn-ghost {
  background: var(--surface);
}
.btn-ghost.is-toggled {
  background: var(--yellow-light);
  border-color: var(--ink);
}

/* ========== INPUTS & FORM CONTROLS ========== */
.text-input, .select-input, .compact-select {
  width: 100%;
  padding: 7px 10px;
  border: var(--border-thin);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  outline: none;
}

.text-input:focus, .select-input:focus, .compact-select:focus {
  box-shadow: 0 0 0 3px var(--yellow);
}

.compact-select {
  width: auto;
  min-height: 34px;
  padding: 4px 10px;
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  margin: 7px 0;
  cursor: pointer;
}

.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
  cursor: pointer;
  flex-shrink: 0;
}

.range-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  font-size: 0.84rem;
  font-weight: 600;
}

.range-field input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
  cursor: pointer;
}

.mini-num {
  width: 44px;
  padding: 2px 5px;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  font-weight: 700;
  text-align: center;
  background: #fff;
}

/* Segmented Control */
.segmented-control {
  display: inline-flex;
  background: var(--surface-alt);
  border: var(--border-thin);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
  box-shadow: var(--shadow-sm);
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink-soft);
  transition: background-color 0.12s, color 0.12s;
}

.seg-btn.is-active {
  background: var(--yellow);
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

/* ========== MODALS & DIALOGS ========== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 36, 48, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
}

.modal-front {
  z-index: 300;
}

.dialog-card {
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(640px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popIn 0.16s cubic-bezier(0.2, 1.25, 0.4, 1);
}

@keyframes popIn {
  from { transform: scale(0.93) translateY(8px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface-alt);
  border-bottom: var(--border-thin);
}

.dialog-header h3 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 800;
}

.dialog-body {
  padding: 16px 18px;
  overflow-y: auto;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  background: var(--surface-alt);
  border-top: var(--border-thin);
}

/* ========== TOAST ========== */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--yellow);
  font-weight: 700;
  font-size: 0.94rem;
  white-space: pre-line; /* "\n" in a toast message starts a new line */
  text-align: center;
  box-shadow: var(--shadow-md);
  z-index: 500;
  animation: popIn 0.15s ease;
}

/* Custom crisp scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #C7BCA6;
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: #9E927C;
}
