/* ============================================================================
 * Threadsheets — Calvin Shirt Designer
 * Dark-navy "design studio" UI. Rebuilt to match the studio reference mock.
 * ==========================================================================*/

:root {
  --app-bg:      #05080f;   /* outermost backdrop */
  --rail-bg:     #0a1020;   /* left tool rail */
  --panel-bg:    #0b1322;   /* inspector / preview panels */
  --panel-2:     #0f1830;   /* nested controls inside a panel */
  --input-bg:    #0a1326;   /* form fields */
  --board-bg:    #080f1f;   /* canvas board */
  --line:        #1b2742;   /* borders */
  --line-soft:   #141d33;
  --text:        #eef1f8;
  --muted:       #8b94ac;
  --muted-2:     #5f6981;
  --accent:      #5b50f5;   /* indigo — primary actions */
  --accent-2:    #6f63ff;
  --accent-press:#4a40e0;
  --accent-soft: rgba(91, 80, 245, .16);
  --accent-line: rgba(91, 80, 245, .55);
  --danger:      #e25563;
  --gold:        #f5b942;
  --radius:      14px;
  --radius-sm:   9px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--app-bg);
  color: var(--text);
  font: 14px/1.45 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body { overflow: hidden; }

.ico    { width: 18px; height: 18px; display: block; fill: none; }
.ico-lg { width: 30px; height: 30px; display: block; fill: none; }

/* ===================== SHELL ===================== */
.studio {
  height: 100vh;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    radial-gradient(900px 520px at 18% -10%, #11183200 0%, transparent 60%),
    var(--app-bg);
}

/* ---- Top bar ---- */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 6px 2px 4px;
}
.brand-title {
  font-family: 'Bitcount Single', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.brand-logo { width: 28px; height: 28px; border-radius: 7px; object-fit: contain; display: block; }
.brand-sub {
  margin-top: 2px;
  font-size: 11px;
  letter-spacing: .35px;
  color: var(--muted);
}

.btn-new {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; color: #fff;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  padding: 9px 15px;
  cursor: pointer;
  box-shadow: 0 6px 18px -8px var(--accent);
  transition: filter .12s, transform .04s;
}
.btn-new:hover { filter: brightness(1.07); }
.btn-new:active { transform: translateY(1px); }
.btn-new .ico { width: 15px; height: 15px; stroke: #fff; }

/* ---- Content row ---- */
.content {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 92px 268px minmax(0, 1fr) 348px;
  gap: 14px;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 0;
}

/* ===================== LEFT RAIL ===================== */
.rail {
  background: var(--rail-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 4px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.nav-item .nav-ico { width: 22px; height: 22px; }
.nav-item:hover { color: var(--text); background: #0e1830; }
.nav-item.active {
  color: #cfd2ff;
  background: var(--accent-soft);
  border-color: var(--accent-line);
  box-shadow: inset 0 0 0 1px rgba(91,80,245,.12);
}

/* ===================== INSPECTOR ===================== */
.inspector {
  display: flex;
  flex-direction: column;
  padding: 16px 16px 14px;
}
.insp-title {
  margin: 2px 2px 14px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .2px;
}
.insp-body { overflow-y: auto; padding-right: 2px; }
.insp-section { display: flex; flex-direction: column; gap: 16px; }
.insp-section[hidden] { display: none; }
[hidden] { display: none !important; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field-label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .2px;
}

input[type="text"], input[type="number"], select {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input[type="text"]:focus, input[type="number"]:focus, select:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--muted-2); }

.select-wrap { position: relative; }
.select-wrap::after {
  content: ""; position: absolute; right: 14px; top: 50%;
  width: 8px; height: 8px; border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted); transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 32px; cursor: pointer;
}
select option { background: #0c1322; color: var(--text); }

/* Size slider */
.slider-row { display: flex; align-items: center; gap: 12px; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 6px; border-radius: 4px;
  background: #1a2440; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
  cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); cursor: pointer;
}
.slider-val {
  min-width: 38px; text-align: right;
  font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text);
}

/* Color rows */
.color-row { display: flex; align-items: center; gap: 8px; }
input[type="color"] {
  width: 38px; height: 38px; padding: 0; flex: 0 0 auto;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: none; cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }
.hex-input { flex: 1; text-transform: uppercase; font-variant-numeric: tabular-nums; }
.px-input {
  display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto;
  background: var(--input-bg); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 0 10px 0 4px;
}
.px-input input { width: 46px; border: none; background: transparent; padding: 9px 4px; text-align: center; }
.px-input input:focus { box-shadow: none; }
.px-input span { font-size: 12px; color: var(--muted); }

/* Segmented (alignment) */
.seg {
  display: inline-flex; gap: 6px;
  background: var(--input-bg); border: 1px solid var(--line);
  border-radius: 11px; padding: 5px;
}
.seg-btn {
  flex: 1; display: grid; place-items: center;
  padding: 8px 16px; border: none; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: background .12s, color .12s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--accent); color: #fff; }
.seg-btn .ico { stroke: currentColor; }

/* Arrange / icon buttons */
.arrange { display: flex; gap: 8px; }
.icon-btn {
  width: 44px; height: 42px; display: grid; place-items: center;
  background: var(--input-bg); border: 1px solid var(--line);
  border-radius: 10px; color: var(--muted); cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.icon-btn:hover { color: var(--text); background: #14203c; border-color: var(--line); }
.icon-btn .ico { stroke: currentColor; }

/* Shapes grid */
.shape-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shape-btn {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 16px 8px; background: var(--input-bg);
  border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); font-size: 12px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.shape-btn:hover { border-color: var(--accent-line); background: #111c38; }
.sw-rect { width: 30px; height: 22px; background: var(--accent); border-radius: 4px; }
.sw-circle { width: 26px; height: 26px; background: var(--accent); border-radius: 50%; }
.sw-tri { width: 0; height: 0; border-left: 15px solid transparent; border-right: 15px solid transparent; border-bottom: 26px solid var(--accent); }
.sw-line { width: 30px; height: 0; border-top: 5px solid var(--accent); border-radius: 4px; }

/* Quick-add (empty state) */
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 2px 0 0; }
.quick-add { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.ghost-btn, .solid-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  border-radius: 10px; padding: 11px 14px;
}
.ghost-btn {
  color: var(--text); background: var(--input-bg); border: 1px solid var(--line);
}
.ghost-btn:hover { border-color: var(--accent-line); background: #111c38; }
.ghost-btn .ico { stroke: currentColor; width: 16px; height: 16px; }
.solid-btn {
  color: #fff; border: 1px solid var(--accent-line);
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
}
.solid-btn:hover { filter: brightness(1.07); }
.solid-btn .ico { stroke: #fff; width: 16px; height: 16px; }

/* Upload drop */
.upload-drop {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 30px 16px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--line); border-radius: 12px;
  color: var(--muted); background: var(--input-bg);
  transition: border-color .12s, color .12s;
}
.upload-drop:hover { border-color: var(--accent-line); color: var(--text); }
.upload-drop .ico-lg { stroke: currentColor; }
.up-title { font-size: 13px; font-weight: 600; color: var(--text); }
.up-sub { font-size: 11px; }

/* Layers list */
.layer-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.layer-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; background: var(--input-bg);
  border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; transition: border-color .12s, background .12s;
}
.layer-row:hover { background: #111c38; }
.layer-row.active { border-color: var(--accent-line); background: var(--accent-soft); }
.layer-row .l-ico { width: 16px; height: 16px; color: var(--muted); flex: 0 0 auto; }
.layer-row .l-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-row .l-del { color: var(--muted-2); display: grid; place-items: center; }
.layer-row .l-del:hover { color: var(--danger); }

/* ===================== WORKSPACE ===================== */
.workspace {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background:
    radial-gradient(1100px 700px at 50% 30%, #0d1730 0%, var(--board-bg) 70%);
  overflow: hidden;
  min-height: 0;
}
.board {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 18px;
  background-image: radial-gradient(rgba(120, 140, 200, .14) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
}
/* The editor stage IS the shirt: its background reflects the chosen color and
   the (transparent) Fabric canvas sits on top. Floating bars overlay it. */
.editor-stage {
  position: relative;
  border-radius: 10px;
  background: #cccccc;            /* set from JS to the selected shirt color */
  box-shadow: 0 30px 80px -34px rgba(0,0,0,.75), inset 0 0 0 1px rgba(0,0,0,.06);
  transition: background .15s ease;
}
.editor-stage .canvas-container { border-radius: 10px; }
.editor-stage canvas { display: block; }

/* floating toolbar (inside the stage, over the shirt) */
.toolbar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 5; display: flex; gap: 8px;
}
.tool-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px; border-radius: 12px;
  background: var(--bar-bg); border: 1px solid var(--bar-line);
  backdrop-filter: blur(6px);
}
.tool-btn {
  width: 36px; height: 32px; display: grid; place-items: center;
  background: transparent; border: none; border-radius: 8px;
  color: var(--bar-ico); cursor: pointer; transition: background .12s, color .12s;
}
.tool-btn:hover { background: var(--bar-hover); }
.tool-btn.active { background: var(--accent); color: #fff; }
.tool-btn .ico { stroke: currentColor; }
.zoom-val { min-width: 44px; text-align: center; font-size: 12.5px; color: var(--bar-ico); font-variant-numeric: tabular-nums; }

/* floating object action bar (inside the stage, over the shirt) */
.object-bar {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  z-index: 5; display: flex; gap: 6px;
  padding: 5px; border-radius: 12px;
  background: var(--bar-bg); border: 1px solid var(--bar-line);
  backdrop-filter: blur(6px);
  transition: opacity .15s;
}
.object-bar.disabled { opacity: .45; pointer-events: none; }
.obj-btn {
  width: 36px; height: 32px; display: grid; place-items: center;
  background: transparent; border: none; border-radius: 8px;
  color: var(--bar-ico); cursor: pointer; transition: background .12s, color .12s;
}
.obj-btn:hover { background: var(--bar-hover); }
.obj-btn.active { color: var(--accent-2); }
.obj-btn.danger:hover { color: #fff; background: var(--danger); }
.obj-btn .ico { stroke: currentColor; }

/* Tool contrast vs the shirt color behind the bars. */
.editor-stage.tools-light {
  --bar-bg: rgba(255,255,255,.72); --bar-line: rgba(0,0,0,.12);
  --bar-ico: #1c2433; --bar-hover: rgba(0,0,0,.08);
}
.editor-stage.tools-dark {
  --bar-bg: rgba(12,18,33,.78); --bar-line: rgba(255,255,255,.14);
  --bar-ico: #f0f2f8; --bar-hover: rgba(255,255,255,.12);
}

/* ===================== PREVIEW ===================== */
.preview {
  display: flex; flex-direction: column;
  padding: 16px;
  gap: 14px;
}
.preview-card {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex; align-items: center; justify-content: center;
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  padding: 6px;
}
.preview-card canvas#mockupCanvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.calibrate-layer { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); height: 100%; width: auto; cursor: crosshair; }

/* palette */
.palette { display: flex; justify-content: center; gap: 14px; flex: 0 0 auto; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.14); cursor: pointer; padding: 0;
  position: relative; transition: transform .08s;
}
.swatch:hover { transform: scale(1.08); }
.swatch.selected { box-shadow: 0 0 0 2px var(--panel-bg), 0 0 0 4px var(--accent); border-color: transparent; }
.swatch .swatch-name {
  position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%);
  font-size: 10px; color: var(--muted); white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .12s;
}
.swatch:hover .swatch-name { opacity: 1; }

.btn-download {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; padding: 14px; cursor: pointer;
  font-size: 14px; font-weight: 700; color: #fff;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border: 1px solid var(--accent-line); border-radius: 12px;
  box-shadow: 0 10px 26px -12px var(--accent);
  transition: filter .12s, transform .04s;
}
.btn-download:hover { filter: brightness(1.07); }
.btn-download:active { transform: translateY(1px); }
.btn-download .ico { stroke: #fff; width: 18px; height: 18px; }

.calibrate-readout {
  display: flex; align-items: center; gap: 8px;
  padding: 10px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px;
}
.calibrate-readout[hidden] { display: none; }
.calibrate-readout input { flex: 1; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.calibrate-readout button {
  font: inherit; font-size: 12px; color: var(--text); cursor: pointer;
  background: var(--input-bg); border: 1px solid var(--line);
  border-radius: 7px; padding: 8px 10px;
}

/* Fabric selection styling tweaks happen in JS (handle colors). */

@media (max-width: 1180px) {
  .content { grid-template-columns: 84px 240px minmax(0,1fr) 300px; }
}

/* ===================== DESKTOP-ONLY GATE ===================== */
/* Hidden by default; shown only when the early detection script flags a
   phone/tablet by adding `device-blocked` to <html>. */
.device-gate { display: none; }
html.device-blocked .studio { display: none; }
html.device-blocked .device-gate {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 28px;
  text-align: center;
  background:
    radial-gradient(900px 520px at 50% -10%, #11183255 0%, transparent 60%),
    var(--app-bg);
}
.device-gate-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: 340px;
}
.device-gate-brand {
  font-size: 30px;
  gap: 12px;
}
.device-gate-brand .brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}
.device-gate-msg {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--muted);
}
