/* Theme Options */
:root,
[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --dim: #64748b;
  --btn: linear-gradient(175deg, #3b82f6 0%, #8b5cf6 100%);
}
[data-theme="light"] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #475569;
  --accent: #2563eb;
  --dim: #94a3b8;
  --btn: linear-gradient(175deg, #2563eb 0%, #7c3aed 100%);
}

/* Globals */
.d-none{display:none;}
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* Disable User Select */
body, html {
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Scrollbar */
body, html{
  scrollbar-width: thin;
  scrollbar-color: #555 transparent;
}
body::-webkit-scrollbar,
html::-webkit-scrollbar {
  height: 5px;
}
body::-webkit-scrollbar-track,
html::-webkit-scrollbar-track {
  background: transparent;
}
body::-webkit-scrollbar-thumb,
html::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 10px;
}
body::-webkit-scrollbar-thumb:hover,
html::-webkit-scrollbar-thumb:hover {
  background: #777;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: #111827;
}
.header-actions .btn{
  color: var(--dim);
  border-color: var(--dim);
}
.header-actions .btn:not(.primary):hover{
  color: #fff;
  background-color: var(--dim);
}
header .btn.primary svg, 
.header-actions .btn:not(.primary):hover svg{
  fill: #fff;
}
header .btn svg{
  height: 1em;
  aspect-ratio: 1;
  fill: var(--dim);
}
.header-actions { display: flex; gap: .5rem; }

/* Logo */
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.35rem; letter-spacing: -0.03em; }
.brand .mark { color: var(--accent); font-size: 1.4rem; }
.brand .mark svg { fill: var(--accent); height: 1.35rem; aspect-ratio: 1; }
.brand span{
  background: linear-gradient(90deg, #4b8ffb 0%, #8e62f4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent; /* Fallback for older browsers */
}
.badge { font-size: .7rem; padding: .15rem .45rem; border-radius: 4px; background: #334155; color: #cbd5e1; }

/* Workspace */

.wrap { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; }
.tabs {
  display: flex;
  gap: .15rem;
  overflow-x: auto;
  border-bottom: 2px solid var(--border);
  scrollbar-width: thin;
}
.tabs button {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  padding: .75rem 1rem;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
}
.tabs button.active { 
  color: var(--text);
  border-image: linear-gradient(90deg, #4b8ffb 0%, #8e62f4 100%);
  border-image-slice: 1;
}
.tabs button:hover:not(.active) { color: #cbd5e1; }

.panel { display: none; padding-top: 1.25rem; }
.panel.active { display: block; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: 1fr 1.4fr; }
.grid-split { grid-template-columns: 340px 1fr; }
@media (max-width: 900px) {
  .grid-2, .grid-split { grid-template-columns: 1fr; }
  header { flex-wrap: nowrap; }
}

h2 { margin: 0 0 1rem; font-size: 1.05rem; display: flex; align-items: center; gap: .45rem; }
.label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: .35rem;
}
.row { display: flex; gap: .5rem; align-items: center; }
input[type="text"], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .7rem;
}
input[type="text"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.25);
}
input[type="color"] {
  width: 64px;
  height: 42px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }

.btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: .5rem .85rem;
  cursor: pointer;
}
.btn:hover { border-color: #94a3b8; }
.btn.primary { background: var(--btn); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { padding: .25rem .5rem; font-size: .8rem; }
.btn.square{padding: 0 .75rem}
.btn.block { width: 100%; }

.swatch {
  height: 120px;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--border);
  border-radius: 6px;
  padding: .4rem .6rem;
  word-break: break-all;
}
.fmt {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem;
}
.fmt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.recent { display: flex; flex-wrap: wrap; gap: .4rem; }
.recent button {
  width: 40px; height: 40px; border-radius: 8px;
  border: 2px solid var(--border); cursor: pointer; padding: 0;
}
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; }
.p-swatch {
  height: 108px;
  border-radius: 10px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.p-swatch .meta {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 1.4rem .5rem .4rem;
  background: linear-gradient(transparent, rgba(15,23,42,.88));
  display: flex; justify-content: space-between; align-items: center;
  font-family: ui-monospace, monospace; font-size: .75rem;
}
pre.out {
  margin: 0;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem;
  background: var(--bg);
  border-radius: 8px;
  padding: .75rem;
  max-height: 180px;
  overflow: auto;
}
.field { margin-bottom: .9rem; }
.stop, .mix-row {
  display: flex; gap: .4rem; align-items: center;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: .4rem .5rem; margin-bottom: .4rem;
}
.mix-row input[type="range"]{
  width: 100%;
}
.stop button, .mix-row button{
  margin-left: auto;
}
.shadow-stage, .glass-stage {
  height: 160px; border-radius: 12px; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  background:
    linear-gradient(135deg, rgba(30,64,175,.25), rgba(51,65,85,.35)),
    var(--surface);
}
.shadow-box {
  width: 160px; height: 90px; border-radius: 12px;
  background: #1e293b; display: flex; align-items: center; justify-content: center;
  color: #94a3b8;
}
.glass-card {
  width: 230px; padding: 1.1rem 1.2rem; border-radius: 16px;
  color: #f8fafc;
}
.cb-row {
  display: grid;
  grid-template-columns: 140px 1fr 1fr;
  gap: .6rem;
  align-items: center;
  margin-bottom: .55rem;
}
.cb-chip {
  display: flex; align-items: center; gap: .45rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: .4rem;
}
.cb-chip i {
  width: 42px; height: 42px; border-radius: 6px; border: 1px solid var(--border); display: block; flex-shrink: 0;
}
.toast-wrap { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: .4rem; z-index: 20; }
.toast {
  background: #0b1220; border: 1px solid #3b82f6; color: #e2e8f0;
  padding: .55rem .8rem; border-radius: 8px; font-size: .85rem;
}
.hint { color: var(--muted); font-size: .78rem; margin-top: .3rem; }
.pass { background: #166534; color: #fff; border-radius: 4px; padding: .1rem .4rem; font-size: .72rem; }
.fail { background: #991b1b; color: #fff; border-radius: 4px; padding: .1rem .4rem; font-size: .72rem; }
.ratio { font-size: 2.4rem; font-weight: 700; color: var(--accent); line-height: 1; }

/* Icon Label */
.icon-label{
  display: flex;
  gap: 6px;
  flex-direction: row;
  flex-wrap: nowrap;
  word-wrap: break-word;
  align-items: center;
  justify-content: start;
}
.icon-label span{
  display: inherit;
}
.icon-label svg{
  height: 1em;
  aspect-ratio: 1;
  fill: #fff;
  margin: 4px 0;
}
@media (max-width: 480px) {
  .icon-label span{
    display:none;
  }
}

/* Modals */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 26px;
  width: min(440px, 94vw);
  box-shadow: 0 0 40px rgba(255,45,149,0.15);
}
.modal h2 {
  font-size: 1.1rem;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 8px;
}
.modal-content{
  max-height: 50vh;
  overflow-y: auto;
  margin: 12px 0px;
}
.modal-content p{
  margin-bottom: 1.5em;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal-actions button { min-width: 90px; }
.modal-actions button svg{ height: 1em; aspect-ratio: 1; fill: #fff; }
body:has(.modal-overlay.show) {overflow: hidden;}