/* ─── RESET & BASE ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Light theme (default) */
  --bg:       #ffffff;
  --surface:  #f4f4f5;   /* zinc-100 */
  --surface2: #e4e4e7;   /* zinc-200 */
  --border:   #d4d4d8;   /* zinc-300 */
  --accent:   #e11d48;   /* rose-600 */
  --accent2:  #0284c7;   /* sky-600  */
  --text:     #09090b;   /* zinc-950 */
  --muted:    #71717a;   /* zinc-500 */
  --canvas-bg:#1a1a1a;
  --radius:   10px;
  --gap:      16px;
}

[data-theme="dark"] {
  --bg:       #09090b;
  --surface:  #18181b;
  --surface2: #27272a;
  --border:   #3f3f46;
  --accent:   #f87171;
  --accent2:  #38bdf8;
  --text:     #fafafa;
  --muted:    #71717a;
  --canvas-bg:#111111;
}

html, body {
  height: 100%;
  font-family: 'Noto Sans JP', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ─── HEADER ────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-icon {
  height: 34px;
  width: auto;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 900;
  color: #c084fc;
  letter-spacing: -0.5px;
}

.header-title {
  flex: 1;
  min-width: 0;
}

header h1 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-sub {
  font-size: 0.72rem;
  color: var(--muted);
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-lang {
  padding: 5px 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}
.btn-lang:hover { border-color: var(--accent2); color: var(--accent2); }

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-icon:hover { border-color: var(--accent2); color: var(--accent2); }

/* ─── SHARE TOAST ────────────────────────────────────────── */
#share-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--surface2);
  border: 1px solid #4ade80;
  color: #86efac;
  padding: 8px 22px;
  border-radius: var(--radius);
  font-size: 0.83rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 999;
}
#share-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── MAIN LAYOUT ───────────────────────────────────────── */
main {
  display: flex;
  height: calc(100vh - 52px);
  overflow: hidden;
}

/* ─── INPUT PANEL ───────────────────────────────────────── */
#input-panel {
  width: 360px;
  min-width: 320px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 6px;
}

.form-section h2 {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--muted);
  margin-bottom: 8px;
}

/* Plate type toggle buttons */
.button-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.type-btn {
  padding: 7px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  transition: all 0.15s;
  font-family: inherit;
}

.type-btn:hover { border-color: var(--accent2); color: var(--text); }
.type-btn.active { border-color: var(--accent2); background: color-mix(in srgb, var(--accent2) 12%, transparent); color: var(--accent2); font-weight: 700; }

/* Text inputs */
.field-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.hint { font-weight: 400; color: var(--muted); font-size: 0.72rem; }

input[type="text"],
select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  font-family: 'Noto Sans JP', monospace;
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus,
select:focus {
  border-color: var(--accent2);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent2);
  margin-top: 4px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  cursor: pointer;
  font-size: 0.88rem;
}

.check-label input[type="checkbox"] {
  accent-color: var(--accent2);
  width: 16px;
  height: 16px;
}

.field-error {
  color: var(--accent);
  font-size: 0.75rem;
  margin-top: 4px;
}

.field-note {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 8px;
  line-height: 1.6;
}

.field-note.warning {
  color: var(--accent);
  margin-top: 2px;
  margin-bottom: 0;
}

.field-note a { color: var(--accent2); }

.font-status {
  font-size: 0.75rem;
  color: var(--accent2);
  margin-top: 4px;
}

.hidden { display: none !important; }

/* ─── ACTIONS ───────────────────────────────────────────── */
.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  letter-spacing: 0.3px;
}

.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn:not(:disabled):hover { opacity: 0.88; }
.btn:not(:disabled):active { transform: scale(0.98); }

.btn-primary  { background: var(--accent2); color: #020617; }
.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:not(:disabled):hover {
  border-color: var(--accent2);
  color: var(--accent2);
  opacity: 1;
}

.btn-row {
  display: flex;
  gap: 6px;
}
.btn-row .btn {
  flex: 1;
}

/* ─── PREVIEW PANEL ─────────────────────────────────────── */
#preview-panel {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preview-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.preview-block h2 {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ─── SVG PREVIEW WRAPPER ───────────────────────────────── */
#svg-preview-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 14px;
  background: #d0d0d0;
  border-radius: 8px;
  border: 1px solid var(--border);
}

[data-theme="dark"] #svg-preview-wrap {
  background: #1e1e20;
}

#svg-preview svg {
  max-width: 100%;
  height: auto;
  border-radius: 5px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
  display: block;
}

/* ─── PLATE COLOR THEMES ── (applied via SVG fill attributes directly) ── */

/* ─── THREE.JS CONTAINER ────────────────────────────────── */
#three-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 7;
  background: var(--canvas-bg);
  border-radius: 6px;
  overflow: hidden;
}

#three-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

#three-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
  pointer-events: none;
}

#three-placeholder.hidden { display: none; }

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 820px) {
  main { flex-direction: column; height: auto; overflow: visible; }
  #input-panel { width: 100%; min-width: unset; border-right: none; border-bottom: 2px solid var(--surface2); overflow-y: visible; }
  #three-container { aspect-ratio: 4 / 3; }
}

/* ─── SCROLLBAR ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }
