/* Quadra — style.css (redesigned) */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&family=DM+Mono:wght@400;500&display=swap');

:root {
  --bg:       #f0efe9;
  --surface:  #ffffff;
  --border:   rgba(0,0,0,0.08);
  --border2:  rgba(0,0,0,0.14);
  --ink:      #111110;
  --ink2:     #5a5a57;
  --ink3:     #9a9a96;
  --ink-inv:  #ffffff;
  --accent:   #111110;
  --r:        16px;
  --r-sm:     9px;
  --nav-h:    52px;
  --sans:     'DM Sans', system-ui, sans-serif;
  --mono:     'DM Mono', monospace;
  --t:        0.18s cubic-bezier(.4,0,.2,1);
  --sh:       0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --sh-md:    0 8px 32px rgba(0,0,0,.1), 0 2px 8px rgba(0,0,0,.06);
  --sh-lg:    0 20px 60px rgba(0,0,0,.12), 0 4px 16px rgba(0,0,0,.08);
  --checker-a: #e8e7e1;
  --checker-b: #f0efe9;
}

[data-theme="dark"] {
  --bg:       #111110;
  --surface:  #1c1c1a;
  --border:   rgba(255,255,255,0.07);
  --border2:  rgba(255,255,255,0.13);
  --ink:      #f0efe9;
  --ink2:     #888884;
  --ink3:     #4a4a47;
  --ink-inv:  #111110;
  --accent:   #f0efe9;
  --sh:       0 1px 3px rgba(0,0,0,.6);
  --sh-md:    0 8px 32px rgba(0,0,0,.5);
  --sh-lg:    0 20px 60px rgba(0,0,0,.6);
  --checker-a: #252522;
  --checker-b: #1c1c1a;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: var(--sans);
  font-size: 14px;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  transition: background var(--t), color var(--t);
}

/* ── NAV ── */
nav {
  position: sticky; top: 0; z-index: 300;
  height: var(--nav-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: .5rem;
  transition: background var(--t), border-color var(--t);
}

.logo {
  display: flex; align-items: center; gap: .45rem;
  font-size: 15px; font-weight: 600; letter-spacing: -.03em;
  color: var(--ink); text-decoration: none; flex-shrink: 0;
  transition: opacity var(--t);
}
.logo:hover { opacity: .55; }
.logo-mark { width: 20px; height: 20px; display: grid; place-items: center; flex-shrink: 0; }
.logo-mark svg { width: 100%; height: 100%; }

.nav-pills {
  display: none;
  justify-content: center;
  gap: 0;
  flex: 1;
}
.nav-pills.show { display: flex; }

.npill {
  padding: 5px 13px;
  font-weight: 500; font-family: var(--sans);
  border: none; background: transparent; color: var(--ink3);
  cursor: pointer; white-space: nowrap; transition: all var(--t);
  letter-spacing: .05em; text-transform: uppercase; font-size: 10px;
}
.npill.active { color: var(--ink); font-weight: 700; }
.npill:hover:not(.active) { color: var(--ink2); }

.nav-right {
  display: flex; align-items: center; gap: .35rem;
  margin-left: auto;
}

.btn-new {
  display: none; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 100px;
  border: 1px solid var(--border2);
  background: transparent; color: var(--ink2);
  font-size: 11.5px; font-weight: 500; font-family: var(--sans);
  cursor: pointer; white-space: nowrap; transition: all var(--t);
}
.btn-new.show { display: flex; }
.btn-new:hover { color: var(--ink); border-color: var(--ink); }
.btn-new svg { width: 10px; height: 10px; stroke: currentColor; }

.theme-toggle {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--border2); background: transparent;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--ink2); transition: all var(--t); flex-shrink: 0;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink); }
.theme-toggle svg { width: 14px; height: 14px; }

[data-theme="light"] .icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: block; }
[data-theme="dark"]  .icon-sun  { display: block; }
[data-theme="dark"]  .icon-moon { display: none; }

.hamburger {
  display: none;
  width: 32px; height: 32px; border-radius: var(--r-sm);
  border: 1px solid var(--border2); background: transparent;
  cursor: pointer; align-items: center; justify-content: center;
  color: var(--ink2); transition: all var(--t); flex-shrink: 0;
}
.hamburger svg { width: 16px; height: 16px; }
.hamburger:hover { color: var(--ink); }

/* Mobile drawer */
.mob-drawer {
  position: fixed; top: var(--nav-h); right: 0;
  width: 210px; z-index: 400;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 0 var(--r);
  padding: .4rem;
  box-shadow: var(--sh-md);
  display: none; flex-direction: column; gap: 2px;
  transform: translateY(-6px);
  opacity: 0;
  transition: opacity .16s, transform .16s;
}
.mob-drawer.open {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}
.mob-drawer .npill {
  text-align: left; padding: 8px 11px;
  border-radius: var(--r-sm);
  text-transform: none; font-size: 13px; letter-spacing: 0;
}
.mob-drawer .npill:hover { background: var(--bg); }
.mob-drawer .npill.active { background: var(--ink); color: var(--ink-inv); }
.drawer-sep { height: 1px; background: var(--border); margin: .2rem 0; }
.drawer-new { color: var(--ink2) !important; font-weight: 500 !important; }

.mob-overlay {
  display: none; position: fixed; inset: 0; z-index: 399;
  background: transparent;
}
.mob-overlay.open { display: block; }

/* ── SCREENS ── */
.screen { display: none; flex: 1; }
.screen.active { display: flex; flex-direction: column; }

/* ── HOME ── */
#home {
  align-items: center; justify-content: flex-start;
  text-align: center;
  padding: 1.5rem 1.5rem 3rem;
  gap: 0;
  min-height: calc(100dvh - var(--nav-h));
}

.home-inner {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  max-width: 400px; width: 100%;
}

.h-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px; border-radius: 100px;
  border: 1px solid var(--border2);
  font-size: 11px; font-weight: 500; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink3);
  margin-bottom: 1.4rem;
}
.h-badge-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--ink3);
}

.h-title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 300; letter-spacing: -.05em; line-height: 1.05;
  color: var(--ink); margin-bottom: .8rem;
}
.h-title strong { font-weight: 600; }

.h-sub {
  font-size: 13.5px; color: var(--ink2); line-height: 1.75;
  margin-bottom: 2.5rem;
}

/* Drop zone — full rounded card */
.dropzone {
  position: relative; overflow: hidden;
  border: 1.5px dashed var(--border2);
  border-radius: var(--r);
  background: var(--surface);
  padding: 2.5rem 3rem;
  cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .5rem;
  transition: border-color var(--t), background var(--t), box-shadow var(--t);
  width: 100%;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--ink);
  border-style: solid;
  background: var(--bg);
}
.dropzone input[type=file] {
  position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer;
}
.dz-icon {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 10px; border: 1.5px solid var(--border2);
  color: var(--ink3); margin-bottom: .25rem;
}
.dz-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.dz-main {
  font-size: 14px; font-weight: 500; color: var(--ink);
}
.dz-sub {
  font-size: 12px; color: var(--ink3);
}

.dz-below {
  margin-top: .9rem; font-size: 12px; color: var(--ink3);
}
.dz-below kbd {
  display: inline-flex; align-items: center;
  padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--border2);
  background: var(--surface);
  font-family: var(--mono); font-size: 11px; color: var(--ink2);
}

/* Pill list of features */
.h-features {
  display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: center; margin-bottom: 2rem;
}
.h-feat {
  padding: 4px 10px; border-radius: 100px;
  border: 1px solid var(--border);
  font-size: 11.5px; color: var(--ink3);
}

/* ── WORKSPACE — unified single card ── */
#workspace {
  padding: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#workspace.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* The unified card: square preview + fixed tools panel, height-driven */
.unified-card {
  display: flex;
  flex-direction: row;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--sh-lg);
  /* Square side = min(available height, available width minus tools panel) */
  --tools-w: 252px;
  --avail-h: calc(100dvh - var(--nav-h) - 20px);
  --avail-w: calc(100vw - 20px - var(--tools-w));
  --square:  min(var(--avail-h), var(--avail-w));
  height: var(--square);
  width: calc(var(--square) + var(--tools-w));
  transition: background var(--t), border-color var(--t);
}

/* ── LEFT: PREVIEW PANE — perfect square ── */
.prev-pane {
  /* Square: height of the card minus topbar and optional bottombar */
  aspect-ratio: 1;
  height: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  transition: border-color var(--t);
  overflow: hidden;
}

.prev-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: 44px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.prev-label {
  font-size: 10px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink3);
}
.prev-dims {
  font-size: 11px; color: var(--ink3);
  font-family: var(--mono);
}

.prev-body {
  flex: 1;
  background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 0 0 / 16px 16px;
  transition: background var(--t);
  touch-action: none;
  overflow: hidden;
  min-height: 0;
  display: flex; align-items: stretch; justify-content: stretch;
}
.prev-body canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Bottom bar inside preview pane */
.prev-bottombar {
  border-top: 1px solid var(--border);
  padding: 0 1rem;
  height: 48px;
  display: none;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}
.prev-bottombar.show { display: flex; }
.pf-label { font-size: 11.5px; color: var(--ink2); white-space: nowrap; }
.pf-val   { font-size: 11.5px; font-weight: 500; color: var(--ink); min-width: 2rem; text-align: right; font-family: var(--mono); font-size: 11px; }
.pf-slider { flex: 1; }
.pf-hint  { font-size: 11px; color: var(--ink3); margin: 0 auto; }

/* ── RIGHT: TOOLS PANE ── */
.tools-pane {
  flex: 0 0 252px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Scrollable options area scrolls independently; download bar stays pinned */
.tool-options {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
.tool-options::-webkit-scrollbar { width: 4px; }
.tool-options::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* Tool selector — tabs row */
.tool-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: .65rem .65rem .4rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tbtn {
  padding: 8px 6px;
  border-radius: 7px; border: none;
  background: transparent; color: var(--ink3);
  font-family: var(--sans); font-size: 12px; font-weight: 400;
  cursor: pointer; text-align: center;
  transition: all var(--t); line-height: 1.3; min-height: 40px;
  display: flex; align-items: center; justify-content: center;
}
.tbtn:hover { background: var(--bg); color: var(--ink2); }
.tbtn.active {
  background: var(--ink); color: var(--ink-inv);
  font-weight: 600;
}

/* Tool options area — padding only, scroll handled by the rule above */
.tool-options {
  padding: .75rem .65rem .5rem;
  display: flex;
  flex-direction: column;
  gap: .8rem;
}

.sub { display: flex; flex-direction: column; gap: .8rem; }
.sub.off { display: none; }

.cg { display: flex; flex-direction: column; gap: 5px; }
.ctop { display: flex; align-items: center; justify-content: space-between; }
.clabel { font-size: 11px; color: var(--ink3); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }
.cval   { font-size: 11px; font-weight: 500; color: var(--ink); font-family: var(--mono); }

/* Section divider with label */
.sec-divider {
  display: flex; align-items: center; gap: .5rem;
  margin: .2rem 0 .1rem;
}
.sec-divider::before, .sec-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.sec-divider-text {
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink3); font-weight: 500; white-space: nowrap;
}

input[type=range] {
  width: 100%; height: 3px; -webkit-appearance: none; appearance: none;
  background: var(--border2); border-radius: 2px; outline: none; display: block; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--ink); cursor: pointer;
  border: 2px solid var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: transform var(--t);
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.15); }

.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
  padding: 4px 10px; border-radius: 100px;
  border: 1px solid var(--border2);
  background: transparent; font-size: 11px; color: var(--ink2);
  cursor: pointer; font-family: var(--sans);
  transition: all var(--t); line-height: 1.4;
  display: inline-flex; align-items: center; min-height: 26px;
}
.chip:hover { border-color: var(--ink2); color: var(--ink); }
.chip.on { background: var(--ink); color: var(--ink-inv); border-color: var(--ink); }
.chip-full { width: 100%; justify-content: center; border-radius: var(--r-sm); padding: 7px; }

.swatches { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.sw {
  width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--border2); cursor: pointer;
  transition: all var(--t); flex-shrink: 0;
}
.sw:hover { transform: scale(1.2); }
.sw.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--ink); }

input[type=color] {
  width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--border2); cursor: pointer;
  padding: 0; background: none; flex-shrink: 0;
  transition: border-color var(--t);
}
input[type=color]:hover { border-color: var(--ink); }

select {
  flex: 1; padding: 7px 22px 7px 9px;
  background: var(--bg); border: 1px solid var(--border2);
  border-radius: var(--r-sm); color: var(--ink);
  font-family: var(--sans); font-size: 12px; outline: none;
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center; background-size: 9px;
  transition: all var(--t);
}
select:focus { border-color: var(--ink); outline: none; }
[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23666' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* ── DOWNLOAD — pinned to bottom of tools pane ── */
.tc-dl {
  padding: .65rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
  /* sticky at bottom */
  position: sticky;
  bottom: 0;
}

.dl-row { display: flex; gap: 6px; margin-bottom: 7px; }
.dl-btn {
  width: 100%; padding: 10px;
  border-radius: var(--r-sm); border: 1.5px solid var(--ink);
  background: transparent; color: var(--ink);
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all var(--t);
  display: flex; align-items: center; justify-content: center;
  gap: 6px; min-height: 42px; letter-spacing: -.01em;
}
.dl-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; flex-shrink: 0; }
.dl-btn:hover { background: var(--ink); color: var(--ink-inv); }
.dl-btn:active { transform: scale(.98); }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 1.25rem; left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--ink); color: var(--ink-inv);
  padding: 7px 16px; border-radius: 100px;
  font-size: 12px; font-weight: 500;
  opacity: 0; pointer-events: none; z-index: 999;
  transition: opacity .2s, transform .2s; white-space: nowrap;
  display: flex; align-items: center; gap: 5px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── RESPONSIVE — MOBILE ── */
@media (max-width: 700px) {
  nav { padding: 0 .75rem; }
  .hamburger { display: flex; }
  .nav-pills  { display: none !important; }
  .btn-new    { display: none !important; }

  #workspace { padding: 0; align-items: stretch; justify-content: flex-start; }

  .unified-card {
    flex-direction: column;
    border-radius: 0;
    border-left: none; border-right: none; border-bottom: none;
    width: 100%;
    height: auto;
    max-height: none;
    min-height: calc(100dvh - var(--nav-h));
  }

  /* On mobile the preview pane is a square: full width × full width */
  .prev-pane {
    aspect-ratio: 1;
    height: auto;
    width: 100%;
    flex-shrink: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .prev-body {
    min-height: 0;
    height: auto;
    max-height: none;
  }
  .prev-body canvas {
    width: 100%;
    height: 100%;
  }

  .tools-pane {
    flex: 1;
    overflow-y: visible;
  }

  .tool-tabs { grid-template-columns: 1fr 1fr; }

  #home { padding: 1.5rem 1.25rem 2.5rem; }
  .h-title { font-size: 1.75rem; }
}

@media (max-width: 380px) {
  .h-title { font-size: 1.5rem; }
}

/* ── RESPONSIVE — DESKTOP ── */
@media (min-width: 701px) {
  .hamburger { display: none; }
}
