:root {
  --bg: #12202c;
  --bg-deep: #0c1620;
  --panel: #f6efde;
  --panel-strong: #fff8ec;
  --panel-muted: rgba(255, 248, 236, 0.76);
  --ink: #182631;
  --ink-soft: #566572;
  --line: rgba(24, 38, 49, 0.12);
  --line-strong: rgba(24, 38, 49, 0.2);
  --accent: #d58b2a;
  --accent-strong: #b56d10;
  --accent-soft: rgba(213, 139, 42, 0.14);
  --success: #2a8f68;
  --danger: #9b3b33;
  --shadow: 0 28px 64px rgba(6, 14, 21, 0.26);
  --radius-lg: 30px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(213, 139, 42, 0.18), transparent 25%),
    radial-gradient(circle at bottom left, rgba(255, 255, 255, 0.08), transparent 24%),
    linear-gradient(180deg, #1a2b39 0%, #0f1821 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", "Aptos", "Helvetica Neue", sans-serif;
  background: transparent;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.88rem 0.95rem;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input[readonly] {
  background: rgba(247, 242, 232, 0.92);
  color: var(--ink-soft);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: rgba(213, 139, 42, 0.58);
  box-shadow: 0 0 0 4px rgba(213, 139, 42, 0.14);
}

textarea {
  resize: vertical;
}

.app-shell {
  width: min(1240px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.35rem 0 2.5rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
  color: #eef5f8;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
}

.brand-lockup h1 {
  margin: 0.15rem 0 0;
  font-size: clamp(1.45rem, 3vw, 1.9rem);
  letter-spacing: -0.04em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(145deg, #f2bb60, #c26f0c);
  color: #0d1822;
  font-weight: 800;
  letter-spacing: 0.05em;
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.2);
}

.topbar-actions,
.account-cluster {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.status-pill,
.panel-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.2rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.9rem;
}

.status-pill {
  background: rgba(255, 255, 255, 0.12);
  color: #fef8ef;
  backdrop-filter: blur(16px);
}

.status-pill::before,
.panel-status::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: #8cf3c0;
}

.status-pill.muted::before,
.panel-status::before {
  background: #f4c16e;
}

.account-chip {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 180px;
  padding: 0.5rem 0.8rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(16px);
}

.account-chip span {
  font-weight: 700;
}

.account-chip small {
  color: rgba(238, 245, 248, 0.72);
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hero,
.panel,
.preview-banner,
.modal-panel {
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.82fr);
  gap: 1.2rem;
  padding: 1.45rem;
}

.hero h2 {
  margin: 0.35rem 0 0.85rem;
  max-width: 11ch;
  font-size: clamp(2.15rem, 6vw, 4.1rem);
  line-height: 0.95;
  letter-spacing: -0.055em;
}

.hero-text,
.modal-text,
.support-text {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.6;
}

.hero-actions,
.preview-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.hero-stage {
  position: relative;
  min-height: 440px;
}

.paper-stack {
  position: absolute;
  inset: 0;
}

.paper {
  position: absolute;
  width: min(100%, 390px);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #fbf5e9, #f2e7d1);
  color: var(--ink);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.36);
}

.paper h3 {
  margin: 0.45rem 0 0;
  font-size: clamp(1.8rem, 4vw, 2.35rem);
  line-height: 1.02;
  letter-spacing: -0.055em;
}

.paper p {
  margin: 0.85rem 0 0;
  color: var(--ink-soft);
  line-height: 1.6;
}

.paper-label {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: rgba(29, 43, 53, 0.55);
}

.paper-back {
  top: 0.5rem;
  right: 0;
  padding: 1.45rem;
  transform: rotate(8deg);
  opacity: 0.8;
}

.paper-middle {
  top: 5.4rem;
  left: 1.1rem;
  padding: 1.65rem;
  transform: rotate(-6deg);
}

.paper-front {
  right: 0.6rem;
  bottom: 0;
  padding: 1.85rem;
}

.paper-lines {
  display: grid;
  gap: 0.9rem;
  margin-top: 1.25rem;
}

.paper-lines span {
  display: block;
  height: 1px;
  background: rgba(29, 43, 53, 0.15);
}

.preview-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  background:
    linear-gradient(180deg, rgba(255, 248, 236, 0.98), rgba(247, 239, 222, 0.96)),
    linear-gradient(90deg, rgba(213, 139, 42, 0.08), transparent);
}

.preview-banner h3 {
  margin: 0.2rem 0 0;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 1.1rem;
}

.workspace-sidebar,
.workspace-main {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.panel {
  padding: 1.1rem;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.95rem;
}

.panel-header h3 {
  margin: 0.22rem 0 0;
  font-size: 1.24rem;
  letter-spacing: -0.035em;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: rgba(86, 101, 114, 0.9);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.field,
.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field span {
  font-size: 0.9rem;
  font-weight: 600;
}

.mode-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.mode-button,
.auth-mode-button {
  border: 1px solid rgba(16, 26, 37, 0.08);
  border-radius: 16px;
  padding: 0.9rem 0.95rem;
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink-soft);
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, color 160ms ease;
}

.mode-button.active,
.auth-mode-button.active {
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  color: #fff8ea;
  box-shadow: 0 14px 28px rgba(181, 109, 16, 0.24);
}

.mode-button:hover,
.auth-mode-button:hover,
.button:hover,
.mini-button:hover {
  transform: translateY(-1px);
}

.draft-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.empty-state {
  padding: 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.44);
  color: var(--ink-soft);
  line-height: 1.55;
}

.draft-item {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.95rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.6);
}

.draft-item.active {
  border-color: rgba(213, 139, 42, 0.36);
  box-shadow: inset 0 0 0 1px rgba(213, 139, 42, 0.18);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(248, 240, 223, 0.96));
}

.draft-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}

.draft-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.draft-meta {
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.draft-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.mini-button,
.button {
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease, background 160ms ease;
}

.mini-button {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.58rem 0.82rem;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 700;
}

.mini-button.danger {
  color: var(--danger);
}

.doc-number {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 180px;
}

.doc-number span {
  color: var(--ink-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.doc-number input {
  text-align: center;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.76);
}

.form-panel {
  min-height: 100%;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.95rem;
}

.form-grid .wide,
.field-group {
  grid-column: 1 / -1;
}

.field-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.95rem;
}

[hidden] {
  display: none !important;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.2rem;
  align-items: center;
}

.button-row.compact {
  margin-top: 0.9rem;
}

.action-hint {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.5;
  font-size: 0.98rem;
}

.button {
  min-height: 3rem;
  border: none;
  border-radius: 16px;
  padding: 0.82rem 1.1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.button.small {
  min-height: 2.6rem;
  padding: 0.65rem 0.95rem;
}

.button.primary {
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  color: #fff8eb;
  box-shadow: 0 14px 30px rgba(181, 109, 16, 0.28);
}

.button.secondary {
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  border: 1px solid var(--line);
}

.button.ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #f4f8fb;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.workspace .button.ghost,
.panel .button.ghost {
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink);
  border: 1px solid var(--line);
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow-y: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 14, 21, 0.58);
  backdrop-filter: blur(6px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(560px, calc(100% - 1rem));
  padding: 1.2rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.modal-copy h2 {
  margin: 0.18rem 0 0.7rem;
  font-size: clamp(1.8rem, 6vw, 2.55rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.modal-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
  transform: rotate(45deg);
}

.auth-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 1rem 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.auth-message {
  margin: 0;
  padding: 0.85rem 0.95rem;
  border-radius: 16px;
  background: rgba(213, 139, 42, 0.12);
  color: #7d4a0f;
  line-height: 1.5;
}

.auth-message.error {
  background: rgba(155, 59, 51, 0.1);
  color: #8e2f27;
}

.auth-submit {
  width: 100%;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 80;
  max-width: min(420px, calc(100% - 2rem));
  padding: 0.95rem 1rem;
  border-radius: 18px;
  background: rgba(16, 26, 37, 0.94);
  color: #edf4f8;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .hero,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .hero h2 {
    max-width: none;
  }

  .hero-stage {
    min-height: 390px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 1rem, 100%);
    padding-top: 0.75rem;
  }

  .topbar,
  .panel-header,
  .preview-banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions,
  .account-cluster,
  .preview-banner-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .hero,
  .panel,
  .preview-banner,
  .modal-panel {
    border-radius: 24px;
  }

  .hero {
    padding: 1.2rem;
  }

  .hero h2 {
    font-size: clamp(2rem, 11vw, 3.4rem);
  }

  .hero-stage {
    min-height: 360px;
  }

  .paper {
    width: 100%;
  }

  .paper-back,
  .paper-middle,
  .paper-front {
    left: 0;
    right: 0;
  }

  .paper-back {
    top: 0.6rem;
    transform: rotate(4deg);
  }

  .paper-middle {
    top: 5.4rem;
    left: 0.25rem;
    transform: rotate(-4deg);
  }

  .paper-front {
    right: 0;
    bottom: 0;
  }

  .form-grid,
  .field-group {
    grid-template-columns: 1fr;
  }

  .button-row,
  .draft-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .button,
  .mini-button {
    width: 100%;
  }

  .action-hint {
    font-size: 0.94rem;
    text-align: center;
  }
}

@media print {
  html,
  body {
    background: #fff;
  }

  .topbar,
  .workspace-sidebar,
  .button-row,
  .toast,
  .preview-banner {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .workspace,
  .workspace-grid {
    display: block;
  }

  .panel,
  .hero {
    border: none;
    box-shadow: none;
    background: #fff;
    padding: 0;
  }
}
