:root {
  --bg: #fdfdfc;
  --ink: #141312;
  --faint: #c9c7c2;
  --ink-10: rgba(20, 19, 18, 0.1);
  --ink-15: rgba(20, 19, 18, 0.15);
  --ink-30: rgba(20, 19, 18, 0.3);
  --ink-40: rgba(20, 19, 18, 0.4);
  --ink-50: rgba(20, 19, 18, 0.5);
  --ink-60: rgba(20, 19, 18, 0.6);
  --ink-70: rgba(20, 19, 18, 0.7);
  --radius-lg: 16px;
  --radius-full: 999px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Open Sauce One', sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

a {
  color: inherit;
  text-decoration: none;
}

textarea, input, button, select {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

::selection {
  background: var(--ink);
  color: var(--bg);
}

.focus-ring:focus-visible,
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.hidden {
  display: none !important;
}

/* ---------- Layout helpers ---------- */

.screen {
  min-height: 100vh;
}

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.wordmark {
  display: block;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.2em;
  text-transform: lowercase;
  color: var(--ink-60);
  margin-bottom: 40px;
}

/* ---------- Landing / blank canvas ---------- */

.splash {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  animation: fadeOut 0.9s ease forwards;
  animation-delay: 1.5s;
}

.splash h1 {
  font-size: 22px;
  letter-spacing: 0.2em;
  text-transform: lowercase;
  font-weight: 400;
  color: var(--ink);
}

@keyframes fadeOut {
  to { opacity: 0; visibility: hidden; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in {
  animation: fadeIn 0.5s ease forwards;
}

.canvas-nav {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 30;
  padding: 22px;
}

.canvas-nav-links {
  display: flex;
  gap: 20px;
  font-size: 14px;
  color: var(--ink-70);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.canvas-nav:hover .canvas-nav-links,
.canvas-nav:focus-within .canvas-nav-links {
  opacity: 1;
}

.canvas-nav-links a {
  padding: 2px 4px;
  border-radius: 4px;
}

.canvas-nav-links a:hover {
  color: var(--ink);
}

.blank-textarea {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100vh;
  resize: none;
  border: none;
  background: transparent;
  padding: 40px 32px;
  font-size: 19px;
  line-height: 1.7;
  color: var(--faint);
  caret-color: var(--ink);
}

.blank-textarea:focus {
  outline: none;
  color: var(--ink);
}

@media (min-width: 640px) {
  .blank-textarea { padding: 64px 64px; }
}
@media (min-width: 768px) {
  .blank-textarea { padding: 96px 128px; }
}

.toast-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 32px;
  z-index: 30;
  display: flex;
  justify-content: center;
}

.toast-pill {
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  border-radius: var(--radius-full);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.toast-pill a, .toast-pill button {
  color: var(--bg);
  background: none;
  border: none;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-size: 14px;
}

.toast-pill button.quiet {
  opacity: 0.7;
  text-decoration: none;
}
.toast-pill button.quiet:hover { opacity: 1; }

.toast-tab {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 30;
  background: var(--ink);
  color: var(--bg);
  border: none;
  padding: 16px 8px;
  border-radius: 10px 0 0 10px;
  font-size: 16px;
  box-shadow: -4px 0 16px rgba(20, 19, 18, 0.12);
}
.toast-tab:hover { padding-right: 12px; }

/* ---------- Device banner ---------- */

.device-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
}

.device-banner-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
}

.device-banner button {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--bg);
  opacity: 0.8;
  padding: 4px 8px;
  border-radius: 4px;
}
.device-banner button:hover { opacity: 1; }

/* ---------- Auth form ---------- */

.auth-card { width: 100%; max-width: 380px; }

.tab-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 32px;
  font-size: 14px;
}

.tab-btn {
  background: none;
  border: none;
  padding-bottom: 4px;
  border-bottom: 1px solid transparent;
  color: var(--ink-40);
}

.tab-btn.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 12px;
  color: var(--ink-50);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  border: 1px solid var(--ink-15);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  background: transparent;
}

.field input:focus {
  border-color: var(--ink-40);
  outline: none;
}

.btn-primary {
  width: 100%;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-outline {
  width: 100%;
  background: transparent;
  border: 1px solid var(--ink-15);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  text-align: center;
  display: inline-block;
}
.btn-outline:hover { background: rgba(20,19,18,0.05); }

.error-text { font-size: 12px; color: #dc2626; margin: 0 0 12px; }
.hint-text { font-size: 12px; color: var(--ink-40); margin-top: 24px; text-align: center; line-height: 1.6; }

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input {
  width: 100%;
  padding-right: 56px;
}

.password-toggle {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  font-size: 12px;
  color: var(--ink-50);
  padding: 6px 8px;
  border-radius: 6px;
}
.password-toggle:hover { color: var(--ink); }

.forgot-link {
  display: block;
  text-align: right;
  font-size: 12px;
  color: var(--ink-50);
  text-decoration: underline;
  text-underline-offset: 2px;
  margin: -8px 0 16px;
}
.forgot-link:hover { color: var(--ink); }

.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-70);
  margin: 4px 0 12px;
  cursor: pointer;
}

.remember-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--ink);
}

/* ---------- Dashboard ---------- */

.dash-layout {
  display: flex;
  height: 100vh;
}

.dash-sidebar {
  width: 224px;
  flex-shrink: 0;
  border-right: 1px solid var(--ink-10);
  padding: 20px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

@media (max-width: 767px) {
  .dash-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 60;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .dash-sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 24px rgba(20, 19, 18, 0.15);
  }
}

.dash-backdrop {
  display: none;
}

@media (max-width: 767px) {
  .dash-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(20, 19, 18, 0.35);
    z-index: 55;
  }
}

.dash-burger {
  display: none;
}

@media (max-width: 767px) {
  .dash-burger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 5px;
    position: fixed;
    top: 18px;
    left: 18px;
    z-index: 70;
    width: 22px;
    height: 14px;
    background: none;
    border: none;
    padding: 0;
  }
  .dash-burger .bar {
    display: block;
    height: 3px;
    border-radius: 2px;
    background: var(--ink);
    transition: transform 0.25s ease, width 0.2s ease;
  }
  .dash-burger .bar:first-child { width: 20px; }
  .dash-burger .bar:last-child { width: 13px; } /* a shorter second bar — small, asymmetric, not a generic 3-line icon */

  .dash-burger.open .bar:first-child {
    width: 20px;
    transform: translateY(8px) rotate(45deg);
  }
  .dash-burger.open .bar:last-child {
    width: 20px;
    transform: translateY(-6px) rotate(-45deg);
  }

  .dash-close-drawer {
    display: block;
    background: none;
    border: none;
    color: var(--ink-50);
    font-size: 12px;
    align-self: flex-end;
    margin-bottom: 12px;
    padding: 4px 6px;
  }
  .dash-generate-mobile {
    display: block;
    width: 100%;
    margin-top: 12px;
  }
  /* The desktop top-right generate button is replaced by the drawer's
     copy on mobile, since everything lives under the burger menu there. */
  .dash-top-actions .btn-pill#generateBtn {
    display: none;
  }
}

.dash-close-drawer {
  display: none;
}

.dash-generate-mobile {
  display: none;
}

.dash-new-btn {
  background: none;
  border: none;
  text-align: left;
  font-size: 14px;
  color: var(--ink-70);
  margin-bottom: 24px;
  padding: 0;
}
.dash-new-btn:hover { color: var(--ink); }

.dash-saved-label {
  font-size: 12px;
  color: var(--ink-40);
  margin-bottom: 8px;
}

.dash-saved-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dash-saved-item {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 6px 8px;
  border-radius: 6px;
  background: none;
  border: none;
  color: var(--ink-50);
}
.dash-saved-item:hover { color: var(--ink); }
.dash-saved-item.active { background: var(--ink-10); color: var(--ink); }

.dash-empty { font-size: 12px; color: var(--ink-30); }

.dash-footer {
  padding-top: 16px;
  border-top: 1px solid var(--ink-10);
  margin-top: 16px;
}

.dash-footer p { font-size: 12px; color: var(--ink-40); margin: 0 0 8px; }
.dash-footer a { font-size: 12px; color: var(--ink-60); }
.dash-footer a:hover { color: var(--ink); }

.dash-main { flex: 1; position: relative; }

.dash-textarea {
  width: 100%;
  height: 100vh;
  resize: none;
  border: none;
  background: transparent;
  padding: 40px 32px;
  font-size: 19px;
  line-height: 1.7;
  color: var(--ink);
  caret-color: var(--ink);
}
.dash-textarea:focus { outline: none; }

@media (max-width: 767px) {
  /* Keeps the first line of typed text clear of the burger icon,
     regardless of exact phone width. */
  .dash-textarea { padding-top: 64px; }
}

@media (min-width: 640px) {
  .dash-textarea { padding: 64px 64px; }
}
@media (min-width: 768px) {
  .dash-textarea { padding: 80px 96px; }
}

.dash-top-actions {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.save-status { font-size: 12px; color: var(--ink-30); }

.btn-pill {
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-full);
  padding: 8px 16px;
  font-size: 12px;
}
.btn-pill:hover { opacity: 0.9; }
.btn-pill:disabled { opacity: 0.3; cursor: not-allowed; }

/* ---------- Modal / image generator ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20,19,18,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: var(--bg);
  border-radius: 20px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

@media (min-width: 640px) {
  .modal-card { padding: 32px; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-head h2 { font-size: 16px; font-weight: 400; margin: 0; }
.modal-head button {
  background: none; border: none; font-size: 14px; color: var(--ink-50);
}
.modal-head button:hover { color: var(--ink); }

.modal-grid {
  display: grid;
  gap: 24px;
}

@media (min-width: 640px) {
  .modal-grid { grid-template-columns: 1fr 1fr; }
}

.canvas-wrap {
  border: 1px solid var(--ink-10);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}

.canvas-wrap canvas { width: 100%; height: auto; display: block; }

.usage-note { font-size: 12px; color: var(--ink-40); }

.option-group { margin-bottom: 20px; }
.option-label { font-size: 12px; color: var(--ink-50); margin-bottom: 8px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  border: 1px solid var(--ink-15);
  background: transparent;
  color: var(--ink-70);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: 12px;
  text-transform: capitalize;
}
.chip:hover { border-color: var(--ink-40); }
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip:disabled { opacity: 0.3; cursor: not-allowed; }
.chip:disabled:hover { border-color: var(--ink-15); }

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--ink-10);
}
.swatch.active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink); }

.limit-box {
  border: 1px solid var(--ink-15);
  border-radius: 12px;
  padding: 16px;
}
.limit-box p { margin: 0 0 8px; font-size: 14px; }
.limit-box p.small { font-size: 12px; color: var(--ink-60); }
.limit-box .btn-outline { display: inline-block; width: auto; margin-top: 4px; padding: 8px 16px; font-size: 12px; background: var(--ink); color: var(--bg); border: none; }

/* ---------- Settings ---------- */

.page-wrap {
  max-width: 420px;
  margin: 0 auto;
  padding: 40px 24px;
}

.back-link { font-size: 12px; color: var(--ink-50); }
.back-link:hover { color: var(--ink); }

.page-title { font-size: 18px; font-weight: 400; margin: 24px 0 32px; }

.settings-row { margin-bottom: 24px; font-size: 14px; }
.settings-row .row-label { font-size: 12px; color: var(--ink-40); margin-bottom: 4px; }
.settings-row .row-flex { display: flex; align-items: center; justify-content: space-between; }
.settings-row a.change-link { font-size: 12px; text-decoration: underline; text-underline-offset: 2px; color: var(--ink-60); }
.settings-row a.change-link:hover { color: var(--ink); }

/* ---------- Pricing ---------- */

.pricing-wrap { max-width: 880px; margin: 0 auto; padding: 48px 24px; }
.pricing-title { font-size: 26px; text-align: center; margin: 0 0 8px; font-weight: 400; }
.pricing-sub { font-size: 14px; color: var(--ink-50); text-align: center; margin: 0 0 40px; }

.toggle-wrap { display: flex; justify-content: center; margin-bottom: 48px; }
.toggle-group {
  display: inline-flex;
  border: 1px solid var(--ink-15);
  border-radius: var(--radius-full);
  padding: 4px;
  font-size: 14px;
}
.toggle-btn {
  background: none; border: none; border-radius: var(--radius-full);
  padding: 6px 16px; color: var(--ink-60);
}
.toggle-btn.active { background: var(--ink); color: var(--bg); }
.toggle-btn .badge { font-size: 10px; opacity: 0.7; margin-left: 6px; }

.plan-grid { display: grid; gap: 20px; }
@media (min-width: 640px) { .plan-grid { grid-template-columns: repeat(3, 1fr); } }

.plan-card {
  position: relative;
  border: 1px solid var(--ink-15);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.plan-card.featured { border-color: var(--ink); }

.plan-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(20, 19, 18, 0.1);
  border-color: var(--ink-40);
}

.plan-card.selected {
  border-color: var(--ink);
  border-width: 2px;
  box-shadow: 0 12px 28px rgba(20, 19, 18, 0.12);
}

.plan-card.selected .plan-name::after {
  content: '✓ Selected';
  display: inline-block;
  margin-left: 8px;
  font-size: 10px;
  color: var(--bg);
  background: var(--ink);
  border-radius: var(--radius-full);
  padding: 2px 8px;
  vertical-align: middle;
}

.plan-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  font-size: 10px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.plan-name { font-size: 14px; color: var(--ink-60); margin: 0 0 4px; }
.plan-price { font-size: 24px; margin: 0 0 4px; }
.plan-price .period { font-size: 12px; color: var(--ink-40); }
.plan-sub { font-size: 12px; color: var(--ink-40); margin: 0 0 16px; }

.plan-features { list-style: none; padding: 0; margin: 0 0 24px; font-size: 14px; color: var(--ink-70); flex: 1; }
.plan-features li { margin-bottom: 8px; }
.plan-features li.dim { font-size: 12px; color: var(--ink-50); }

.plan-cta {
  text-align: center;
  font-size: 12px;
  border: 1px solid var(--ink-15);
  border-radius: 10px;
  padding: 10px;
  color: var(--ink-50);
}
.plan-cta.free { color: var(--ink); }
.plan-cta.free:hover { background: rgba(20,19,18,0.05); }
.plan-cta.upgrade {
  background: var(--ink); color: var(--bg); border: none; font-size: 14px; padding: 10px;
}
.plan-cta.upgrade:hover { opacity: 0.9; }

/* ---------- Upgrade / success ---------- */

.upgrade-toggle { display: flex; gap: 8px; margin-bottom: 24px; }
.upgrade-toggle button {
  flex: 1; border: 1px solid var(--ink-15); border-radius: 10px; padding: 10px; font-size: 14px;
  background: transparent; color: var(--ink-70);
}
.upgrade-toggle button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.total-row {
  border: 1px solid var(--ink-15);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 24px;
}
.total-row span:first-child { color: var(--ink-60); }

.disclaimer { font-size: 12px; color: var(--ink-40); margin-bottom: 24px; }
