/* Sunstone Review — tokens from the design system (Night Temple theme) */
:root {
  --surface-0: #15120f;
  --surface-1: #211c17;
  --surface-2: #2d2620;
  --edge: #4a3f33;
  --hairline: #3a312a;
  --ink: #efe6d6;
  --ink-muted: #b3a68e;
  --sun: #e3a82a;
  --slot-right: #2f9470;
  --slot-left: #cd4a2e;
  --slot-up: #3fb0bd;
  --alert: #f0c35a;

  --display: "Cinzel", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;

  --space-1: 4px; --space-2: 8px; --space-3: 16px; --space-4: 24px; --space-5: 48px;
  --radius-sm: 2px; --radius-md: 6px; --radius-lg: 14px;
  --shadow-card: 0 1px 0 var(--edge) inset, 0 8px 24px rgba(0,0,0,.45);
  --fast: 120ms; --base: 200ms; --sheet: 280ms;
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='128' height='128'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .5 0'/></filter><rect width='128' height='128' filter='url(%23n)'/></svg>");
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--surface-0); color: var(--ink); }
body {
  font-family: var(--sans); font-size: 17px; line-height: 22px;
  display: flex; flex-direction: column; min-height: 100dvh;
  overscroll-behavior: none; -webkit-user-select: none; user-select: none;
}
h1, h2, p { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
kbd { font-family: var(--mono); font-size: 11px; line-height: 16px; letter-spacing: .04em; }
.caption { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.label { font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); }
.title { font-family: var(--display); font-size: 22px; line-height: 28px; font-weight: 600; letter-spacing: .02em; }

/* worn stone: flat fill, 1px lit edge on top, hairline below, faint grain */
.stone {
  background: var(--surface-1); border-radius: var(--radius-sm);
  box-shadow: 0 1px 0 var(--edge) inset, 0 -1px 0 var(--hairline) inset;
  position: relative;
}
.stone::after, .bar::after, .top::after, .sheet::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: var(--grain); opacity: .04; border-radius: inherit;
}

/* header */
.top {
  position: relative; padding: calc(env(safe-area-inset-top) + var(--space-2)) var(--space-3) 0;
  background: var(--surface-1); box-shadow: 0 -1px 0 var(--hairline) inset;
}
.top-row { display: flex; align-items: center; justify-content: space-between; min-height: var(--space-5); }
.brand { font-family: var(--display); font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: .04em; color: var(--sun); }
.top-tools { display: flex; align-items: center; gap: var(--space-2); }
.icon-btn { width: 44px; height: 44px; border-radius: var(--radius-md); display: grid; place-items: center; }
.icon-btn:active, .icon-btn.on { background: var(--surface-2); }
.icon-btn svg, .slot-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; }
.icon-btn.muted svg { opacity: .45; }
.fret {
  height: 8px; margin: var(--space-1) 0 0;
  background:
    linear-gradient(90deg, var(--hairline) 8px, transparent 8px) 0 0 / 16px 8px repeat-x,
    linear-gradient(90deg, transparent 8px, var(--hairline) 8px) 0 0 / 16px 4px repeat-x;
  opacity: .9;
}
.status { display: flex; justify-content: space-between; padding: var(--space-1) 0 var(--space-2); }
.density { display: flex; align-items: center; gap: var(--space-1); margin-right: var(--space-2); }
.density .label { margin-right: var(--space-1); }
.density button { min-width: 32px; height: 32px; border-radius: var(--radius-md); font-family: var(--mono); font-size: 13px; color: var(--ink-muted); }
.density button.on { background: var(--surface-2); color: var(--ink); box-shadow: 0 1px 0 var(--edge) inset; }

/* stage */
.stage { flex: 1; position: relative; padding: var(--space-3); min-height: 0; }
.stack { position: relative; height: 100%; touch-action: none; }
.card {
  position: absolute; inset: 0; margin: auto;
  background: var(--surface-1); border-radius: var(--radius-sm);
  box-shadow: 0 1px 0 var(--edge) inset, 0 -1px 0 var(--hairline) inset;
  overflow: hidden; will-change: transform; z-index: 2;
  transition: transform var(--base) cubic-bezier(.2,.7,.3,1);
}
.card.dragging { transition: none; box-shadow: var(--shadow-card); z-index: 3; }
.card.under { transform: scale(.96) translateY(8px); opacity: .7; z-index: 1; }
.card img { width: 100%; height: 100%; object-fit: contain; display: block; background: var(--surface-0); pointer-events: none; -webkit-user-drag: none; }
.card .tint { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.card .star { position: absolute; top: var(--space-2); right: var(--space-2); width: 32px; height: 32px; opacity: 0; transition: opacity var(--fast); }
.card .star svg { width: 32px; height: 32px; fill: var(--sun); stroke: var(--surface-0); stroke-width: 1; }
.card.fav .star { opacity: 1; }
.card .meta { position: absolute; left: 0; right: 0; bottom: 0; padding: var(--space-2) var(--space-3); background: rgba(21,18,15,.72); color: var(--ink-muted); font-size: 13px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .filed { position: absolute; top: var(--space-2); left: var(--space-2); padding: 2px var(--space-2); border-radius: var(--radius-sm); font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--surface-0); display: none; }
.card.slot-left .filed { display: block; background: var(--slot-left); }
.card.slot-up .filed { display: block; background: var(--slot-up); }
.card.slot-right .filed { display: block; background: var(--slot-right); }

/* grid (wide viewports only) */
.grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(var(--cols, 2), 1fr); height: 100%; overflow: auto; align-content: start; align-items: start; }
.grid .card { position: relative; inset: auto; margin: 0; height: 0; padding-bottom: 100%; }  /* square cell the row track can size */
.grid .card img { position: absolute; inset: 0; }
.grid .card.hl { outline: 2px solid var(--sun); outline-offset: 2px; }

.empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: var(--space-2); padding: var(--space-4); }

/* bottom bar */
.bar {
  position: relative; background: var(--surface-2);
  box-shadow: 0 1px 0 var(--edge) inset;
  padding: 0 var(--space-2) calc(env(safe-area-inset-bottom) + var(--space-2));
}
.stair { display: flex; gap: 2px; height: var(--space-2); padding: 0 var(--space-2); overflow: hidden; }
.stair i { flex: 1 0 auto; min-width: 2px; background: var(--hairline); border-radius: 1px; }
.stair i.lit { background: var(--sun); }
.actions { display: flex; gap: var(--space-2); padding-top: var(--space-2); }
.slot-btn {
  flex: 1; min-height: 56px; border-radius: var(--radius-md);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink); transition: transform var(--fast), background var(--fast);
  box-shadow: 0 1px 0 var(--edge) inset; background: var(--surface-1);
}
.slot-btn .arrow { font-size: 20px; line-height: 22px; }
.slot-btn .name { font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-btn kbd { color: var(--ink-muted); }
.slot-btn:active, .slot-btn.lift { transform: translateY(-3px); }
.slot-btn[data-slot="left"] .arrow { color: var(--slot-left); }
.slot-btn[data-slot="up"] .arrow { color: var(--slot-up); }
.slot-btn[data-slot="right"] .arrow { color: var(--slot-right); }
.slot-btn[data-slot="left"].lift { background: var(--slot-left); color: var(--surface-0); }
.slot-btn[data-slot="up"].lift { background: var(--slot-up); color: var(--surface-0); }
.slot-btn[data-slot="right"].lift { background: var(--slot-right); color: var(--surface-0); }
.slot-btn.lift kbd, .slot-btn.lift .arrow { color: inherit; }
.slot-btn.fav svg { fill: none; stroke: var(--sun); }
.slot-btn.fav[aria-pressed="true"] svg { fill: var(--sun); }
.slot-btn.undo { flex: .8; }
.slot-btn:focus-visible { outline: 2px solid var(--sun); outline-offset: 2px; }

/* bottom sheet */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 9; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--surface-1); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 1px 0 var(--edge) inset;
  padding: var(--space-4) var(--space-3) calc(env(safe-area-inset-bottom) + var(--space-4));
  display: flex; flex-direction: column; gap: var(--space-3);
  transform: translateY(0); transition: transform var(--sheet) cubic-bezier(.2,.7,.3,1);
  max-width: 560px; margin: 0 auto;
}
.field { display: grid; grid-template-columns: 16px 1fr; grid-template-rows: auto auto; column-gap: var(--space-2); align-items: center; }
.field .swatch { width: 16px; height: 16px; border-radius: var(--radius-sm); grid-row: 1 / 3; }
.swatch.left { background: var(--slot-left); } .swatch.up { background: var(--slot-up); } .swatch.right { background: var(--slot-right); }
.field .hint { font-size: 11px; line-height: 16px; color: var(--ink-muted); font-family: var(--mono); }
.field input {
  font: inherit; color: var(--ink); background: var(--surface-0); border: 1px solid var(--hairline);
  border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); min-height: 44px; width: 100%;
}
.field input:focus { outline: 2px solid var(--sun); outline-offset: 1px; border-color: transparent; }
.sheet-actions { display: flex; gap: var(--space-2); justify-content: flex-end; }
.btn { min-height: 44px; padding: 0 var(--space-3); border-radius: var(--radius-md); display: inline-flex; align-items: center; text-decoration: none; font-weight: 600; }
.btn.primary { background: var(--sun); color: var(--surface-0); }
.btn.ghost { color: var(--ink); box-shadow: 0 0 0 1px var(--hairline) inset; }

/* toast */
.toast {
  position: fixed; left: var(--space-3); right: var(--space-3); top: calc(env(safe-area-inset-top) + var(--space-3));
  margin: 0 auto; max-width: 440px; z-index: 20;
  background: var(--surface-2); color: var(--ink); border-radius: var(--radius-md);
  box-shadow: 0 1px 0 var(--edge) inset, 0 8px 24px rgba(0,0,0,.45);
  padding: var(--space-2) var(--space-3); display: flex; gap: var(--space-2); align-items: center;
  font-size: 13px; line-height: 18px;
}
.toast .dot { width: 8px; height: 8px; border-radius: 4px; background: var(--alert); flex: none; }

@media (prefers-reduced-motion: reduce) {
  .card, .slot-btn, .sheet { transition: none; }
}
