:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --paper: #fffdf7;
  --paper-strong: #ffffff;
  --ink: #1d2433;
  --ink-soft: #4b5565;
  --ink-muted: #7b8494;
  --line: #d9d2c4;
  --line-strong: #b9ae9b;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --blue: #2563eb;
  --yellow: #f2b705;
  --red: #dc2626;
  --shadow: 0 18px 50px rgba(42, 34, 19, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
  padding: 0.7rem clamp(1rem, 3vw, 2rem);
  background: rgba(255, 253, 247, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  user-select: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: #1d2433;
  color: #fffdf7;
  box-shadow: 0 10px 24px rgba(29, 36, 51, 0.22);
  flex: 0 0 auto;
}

.brand-text {
  display: grid;
  line-height: 1.15;
}

.brand-name {
  font-weight: 800;
  letter-spacing: 0;
}

.brand-sub {
  color: var(--ink-muted);
  font-size: 0.82rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 650;
  font-size: 0.92rem;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius);
}

.site-nav a:hover {
  color: var(--ink);
  background: #ece5d8;
}

.workspace {
  min-height: calc(100vh - 64px);
  display: grid;
  grid-template-rows: auto minmax(520px, 1fr);
  border-bottom: 1px solid var(--line);
  user-select: none;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem clamp(0.75rem, 2vw, 1.25rem);
  background: #eee7db;
  border-bottom: 1px solid var(--line);
}

.toolbar-groups {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.tool-group,
.control-group,
.action-group {
  display: flex;
  align-items: center;
  gap: 0.28rem;
  min-height: 40px;
  padding: 0.28rem;
  border: 1px solid rgba(185, 174, 155, 0.7);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.72);
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  outline: none;
  color: var(--ink);
  background: #f9f5ec;
  border-color: var(--line);
}

.icon-btn.is-active {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.icon-btn svg {
  width: 19px;
  height: 19px;
  stroke-width: 2;
}

.text-btn,
.primary-btn,
.outline-btn,
.danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 0.55rem 0.78rem;
  font-weight: 750;
  cursor: pointer;
  text-decoration: none;
}

.text-btn {
  color: var(--ink-soft);
  background: transparent;
}

.text-btn:hover {
  color: var(--ink);
  background: #f9f5ec;
}

.primary-btn {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.22);
}

.primary-btn:hover {
  background: var(--accent-strong);
}

.outline-btn {
  color: var(--ink);
  background: #fffdf7;
  border-color: var(--line-strong);
}

.outline-btn:hover {
  background: #f5efe4;
}

.danger-btn {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.danger-btn:hover {
  background: #b91c1c;
}

.tool-select {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fffdf7;
  color: var(--ink);
  padding: 0 0.45rem;
  max-width: 10rem;
}

.swatches {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
}

.swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #fffdf7;
  box-shadow: 0 0 0 1px var(--line-strong);
  cursor: pointer;
}

.swatch.is-active {
  box-shadow: 0 0 0 2px var(--ink);
}

.width-control {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0 0.4rem;
  color: var(--ink-muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.width-control input {
  width: 86px;
  accent-color: var(--accent);
}

.stage-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  min-height: 0;
}

.stage {
  position: relative;
  min-width: 0;
  min-height: 520px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(217, 210, 196, 0.38) 1px, transparent 1px),
    linear-gradient(0deg, rgba(217, 210, 196, 0.38) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
}

#boardCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 520px;
  cursor: crosshair;
  touch-action: none;
}

/* Pencil cursor for free draw, matching the toolbar's Lucide pencil icon.
   Hotspot "2 22" sits on the pencil tip (bottom-left of the 24x24 glyph). */
.stage[data-tool="pen"] #boardCanvas {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%23fffdf7' stroke='%231d2433' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z'/%3E%3Cpath d='m15 5 4 4'/%3E%3C/svg%3E") 2 22, crosshair;
}

.stage.is-panning #boardCanvas {
  cursor: grab;
}

.text-editor {
  position: absolute;
  z-index: 20;
  min-width: 120px;
  min-height: 44px;
  resize: both;
  border: 2px solid var(--accent);
  border-radius: 7px;
  padding: 0.45rem 0.55rem;
  background: rgba(255, 253, 247, 0.88);
  color: var(--ink);
  box-shadow: var(--shadow);
  user-select: text;
  pointer-events: auto;
  caret-color: var(--accent);
  outline: none;
  text-align: center;
  font-weight: 700;
  line-height: 1.25;
}

.status-bar {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 4;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  max-width: min(520px, 80vw);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  color: #fff;
  background: rgba(29, 36, 51, 0.92);
  box-shadow: var(--shadow);
  pointer-events: none;
}

.zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.28rem;
  border: 1px solid rgba(185, 174, 155, 0.7);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.9);
  pointer-events: auto;
}

.zoom-label {
  min-width: 58px;
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 750;
  text-align: center;
}

.inspector {
  display: grid;
  align-content: start;
  gap: 1rem;
  padding: 1rem;
  border-left: 1px solid var(--line);
  background: #fbf7ef;
  overflow: auto;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-strong);
  padding: 0.95rem;
}

.panel h2,
.panel h3 {
  margin: 0 0 0.7rem;
  font-size: 0.95rem;
}

.metric-list {
  display: grid;
  gap: 0.55rem;
}

.metric {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.metric strong {
  color: var(--ink);
}

.pro-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: fit-content;
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  color: #14532d;
  background: #dcfce7;
  font-size: 0.78rem;
  font-weight: 800;
}

.quota-warning {
  margin: 0.7rem 0 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.export-options {
  display: grid;
  gap: 0.45rem;
}

.export-options button {
  justify-content: flex-start;
  text-align: left;
}

.premium-lock {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.content {
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 5rem) 1.25rem;
  user-select: text;
}

.content-header {
  max-width: 760px;
  margin-bottom: 2rem;
}

.kicker {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.content h1,
.content h2 {
  margin: 0.35rem 0 0.8rem;
  line-height: 1.08;
  letter-spacing: 0;
}

.content h1 {
  font-size: clamp(2.2rem, 5vw, 4.6rem);
}

.content h2 {
  font-size: clamp(1.8rem, 3vw, 2.8rem);
}

.lead {
  color: var(--ink-soft);
  font-size: clamp(1.05rem, 2vw, 1.28rem);
  line-height: 1.7;
}

.grid-3,
.grid-2 {
  display: grid;
  gap: 1rem;
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.plans-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(4, 1fr);
  align-items: stretch;
}

@media (max-width: 1040px) {
  .plans-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .plans-grid {
    grid-template-columns: 1fr;
  }
}

.plan {
  position: relative;
  display: flex;
  flex-direction: column;
}

.plan .primary-btn,
.plan .outline-btn {
  margin-top: auto;
  align-self: flex-start;
}

.plan-tag {
  position: absolute;
  top: -0.7rem;
  right: 1rem;
  background: #f2b705;
  color: #1d2433;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(42, 34, 19, 0.18);
}

.info-card,
.plan {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-strong);
  padding: 1.2rem;
  box-shadow: 0 10px 28px rgba(42, 34, 19, 0.07);
}

.info-card h3,
.plan h3 {
  margin: 0 0 0.55rem;
}

.info-card p,
.plan p,
.legal p,
.legal li,
.faq p {
  color: var(--ink-soft);
  line-height: 1.72;
}

.plan.featured {
  color: #fffdf7;
  background: #1d2433;
  border-color: #1d2433;
}

.plan.featured p,
.plan.featured li {
  color: rgba(255, 253, 247, 0.78);
}

.price {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  margin: 0.8rem 0 1rem;
}

.price strong {
  font-size: 2.4rem;
}

.check-list {
  padding-left: 1.2rem;
  margin: 1rem 0;
}

.check-list li {
  margin: 0.45rem 0;
}

.faq {
  border-top: 1px solid var(--line);
  padding: 1.25rem 0;
}

.faq h3 {
  margin: 0 0 0.35rem;
}

.site-footer {
  padding: 2.5rem 1.25rem;
  color: var(--ink-muted);
  background: #1d2433;
}

.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: #fffdf7;
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1rem;
  user-select: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(29, 36, 51, 0.55);
}

.modal-card {
  position: relative;
  width: min(520px, 100%);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--paper-strong);
  box-shadow: var(--shadow);
  padding: 1.35rem;
}

.modal-card h2 {
  margin: 0 2rem 0.5rem 0;
}

.modal-card p {
  color: var(--ink-soft);
  line-height: 1.6;
}

.modal-close {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffdf7;
  cursor: pointer;
}

.form-grid {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
}

.form-grid label {
  display: grid;
  gap: 0.32rem;
  color: var(--ink);
  font-weight: 750;
}

.form-grid input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0.7rem 0.75rem;
  background: #fffdf7;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.modal-error {
  color: var(--red);
  font-weight: 700;
}

.page-card {
  width: min(760px, calc(100% - 2rem));
  margin: clamp(2rem, 8vw, 5rem) auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-strong);
  box-shadow: var(--shadow);
  padding: clamp(1.5rem, 5vw, 3rem);
  user-select: text;
}

.page-card h1 {
  margin: 0 0 0.7rem;
  font-size: clamp(2rem, 5vw, 3.3rem);
  line-height: 1.08;
}

.license-card {
  margin-top: 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  background: #f8f4eb;
}

.license-label {
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.license-key-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin: 0.55rem 0;
}

.license-key-row code {
  font-size: 1.1rem;
  font-weight: 800;
  word-break: break-word;
}

.legal {
  max-width: 820px;
  margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 5rem) 1.25rem;
  user-select: text;
}

.legal h1 {
  margin: 0 0 0.45rem;
  font-size: clamp(2rem, 5vw, 3.3rem);
}

.legal h2 {
  margin: 2rem 0 0.6rem;
}

.updated {
  color: var(--ink-muted);
  margin-bottom: 2rem;
}

.legal a {
  color: var(--accent);
  font-weight: 700;
}

.hidden-file {
  display: none;
}

@media (max-width: 1040px) {
  .toolbar {
    grid-template-columns: 1fr;
  }

  .stage-wrap {
    grid-template-columns: 1fr;
  }

  .inspector {
    grid-template-columns: repeat(3, 1fr);
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .site-header {
    position: relative;
    align-items: flex-start;
    flex-direction: column;
  }

  .site-nav {
    justify-content: flex-start;
  }

  .workspace {
    grid-template-rows: auto minmax(460px, 1fr);
  }

  .toolbar-groups {
    align-items: stretch;
  }

  .tool-group,
  .control-group,
  .action-group {
    overflow-x: auto;
    max-width: 100%;
  }

  .stage {
    min-height: 460px;
  }

  #boardCanvas {
    min-height: 460px;
  }

  .inspector,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .status-bar {
    align-items: stretch;
    flex-direction: column;
  }
}

/* ---- Studio page: lock to viewport height, no page scroll, collapsible panel ---- */
body.studio-page {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.studio-page main {
  flex: 1 1 auto;
  min-height: 0;
}

body.studio-page .workspace {
  height: 100%;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  border-bottom: 0;
}

body.studio-page .stage,
body.studio-page #boardCanvas {
  min-height: 0;
}

/* The marketing footer is hidden in the studio so the wheel never scrolls the page. */
body.studio-page .site-footer {
  display: none;
}

.stage-wrap {
  position: relative;
}

.inspector-toggle {
  position: absolute;
  top: 0.75rem;
  right: 282px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-strong);
  color: var(--ink);
  box-shadow: 0 6px 16px rgba(42, 34, 19, 0.16);
  cursor: pointer;
  transition: right 0.18s ease, background 0.18s ease;
}

.inspector-toggle:hover {
  background: #fff;
}

.inspector-toggle i {
  width: 18px;
  height: 18px;
}

.stage-wrap.panel-collapsed {
  grid-template-columns: minmax(0, 1fr) 0;
}

.stage-wrap.panel-collapsed .inspector {
  width: 0;
  padding: 0;
  border-left: 0;
  overflow: hidden;
}

.stage-wrap.panel-collapsed .inspector-toggle {
  right: 0.75rem;
}

@media (max-width: 1040px) {
  /* Stacked layout on small screens: panel sits below the stage, toggle hidden,
     and any collapsed state is neutralized so the panel stays reachable. */
  .inspector-toggle {
    display: none;
  }

  body.studio-page {
    height: auto;
    overflow: visible;
    display: block;
  }

  body.studio-page .site-footer {
    display: block;
  }

  .stage-wrap.panel-collapsed {
    grid-template-columns: 1fr;
  }

  .stage-wrap.panel-collapsed .inspector {
    width: auto;
    padding: 1rem;
    border-left: 0;
    overflow: auto;
  }
}
