:root {
  --ui-panel: #fffaf0;
  --accent: #8a5a26;
  --text: #151515;
  --paper: #fffdf8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text);
  background: radial-gradient(circle at top, #f8f0df 0%, #efe3cc 38%, #e6d7bb 100%);
}

.workspace {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 24px;
  padding: 24px;
}

.panel {
  align-self: start;
  background: var(--ui-panel);
  border: 1px solid rgba(31, 31, 31, 0.12);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 14px 40px rgba(63, 45, 21, 0.12);
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.back-link {
  display: inline-block;
  margin: 0 0 12px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

/* .back-link's own `display: inline-block` above is an author-stylesheet rule, so it always
   beats the browser's built-in `[hidden] { display: none }` default (author rules beat
   user-agent rules regardless of specificity) — any .back-link toggled via el.hidden needs this
   explicit override, or hiding it silently does nothing. !important because an inline
   `style="display:..."` on the element (e.g. to force it onto its own line when visible) would
   otherwise also outrank this. */
.back-link[hidden] {
  display: none !important;
}

h1 {
  margin: 0 0 10px;
  font-size: 1.8rem;
  line-height: 1.05;
  padding-right: 96px;
}

.intro {
  margin: 0 0 18px;
  font-size: 0.98rem;
  line-height: 1.45;
  padding-right: 96px;
}

.field {
  margin-bottom: 16px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
  font-size: 0.95rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
select {
  width: 100%;
  font: inherit;
  color: inherit;
}

input[type="text"],
input[type="email"],
input[type="password"],
select {
  border: 1px solid rgba(31, 31, 31, 0.18);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}

input[type="range"] {
  width: 100%;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.range-value {
  min-width: 4rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: #fffaf2;
}

button.secondary {
  background: #ded3bd;
  color: #2a2116;
}

.wordmark-o {
  color: var(--accent);
}

.entry-list {
  margin-bottom: 8px;
}

.entry {
  border-top: 1px dashed rgba(31, 31, 31, 0.18);
  margin-top: 16px;
  padding-top: 16px;
}

.entry:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

.entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.entry-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.remove-entry {
  appearance: none;
  border: 0;
  background: #ded3bd;
  color: #2a2116;
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.image-status {
  margin-top: 6px;
  font-size: 0.82rem;
  color: #7c7468;
}

.add-entry-button {
  width: 100%;
  margin-top: 4px;
}

.add-entry-button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.number-value {
  width: 4.2rem;
  font: inherit;
  color: inherit;
  border: 1px solid rgba(31, 31, 31, 0.18);
  border-radius: 12px;
  padding: 6px 8px;
  background: #fff;
  text-align: right;
}

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

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--ui-panel);
  border: 1px solid rgba(31, 31, 31, 0.12);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 14px 40px rgba(63, 45, 21, 0.12);
  position: relative;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.auth-tab {
  flex: 1;
  background: #ded3bd;
  color: #2a2116;
}

.auth-tab.active {
  background: var(--accent);
  color: #fffaf2;
}

.form-error {
  margin: -6px 0 14px;
  font-size: 0.88rem;
  color: #a3311a;
}

.form-note {
  margin: 14px 0 0;
  font-size: 0.88rem;
  line-height: 1.4;
  color: #4a4238;
}

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.status-badge.active {
  background: #dcecd6;
  color: #275c1d;
}

.status-badge.none,
.status-badge.canceled,
.status-badge.past_due {
  background: #f3ddd4;
  color: #8a3418;
}

.status-badge.trialing,
.status-badge.paused {
  background: #f3e6cf;
  color: #7a5518;
}

.lang-switch {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 6px;
}

.lang-flag {
  min-width: 40px;
  padding: 6px 8px;
  border-radius: 999px;
  background: #f3e6cf;
  color: #2a2116;
  font-size: 0.95rem;
  line-height: 1;
}

.lang-flag.active {
  background: var(--accent);
  color: #fffaf2;
}

.help {
  margin: 18px 0 0;
  padding-left: 18px;
  line-height: 1.45;
  font-size: 0.93rem;
}

.preview-wrap {
  overflow: auto;
  padding: 12px;
}

.sheet {
  width: 297mm;
  height: 210mm;
  margin: 0 auto 24px;
  background: var(--paper);
  box-shadow: 0 18px 50px rgba(36, 25, 10, 0.18);
  display: grid;
  place-items: center;
  break-inside: avoid;
  page-break-inside: avoid;
}

.sheet:last-child {
  margin-bottom: 0;
}

.sheet-svg {
  width: 297mm;
  height: 210mm;
  display: block;
  background: #fff;
}

@page {
  size: A4 landscape;
  margin: 0;
}

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

  .preview-wrap {
    padding: 0;
  }

  .sheet {
    transform-origin: top center;
    transform: scale(0.78);
    margin: -18mm auto -18mm;
  }
}

@media print {
  html,
  body {
    margin: 0;
    padding: 0;
    width: 297mm;
    overflow: visible;
  }

  body {
    background: #fff;
  }

  .workspace {
    display: block;
    padding: 0;
  }

  .panel {
    display: none;
  }

  .preview-wrap {
    padding: 0;
    overflow: visible;
  }

  .sheet {
    width: 297mm;
    height: 210mm;
    margin: 0;
    box-shadow: none;
    display: block;
    background: #fff;
    break-after: page;
    page-break-after: always;
  }

  .sheet:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .sheet-svg {
    width: 297mm;
    height: 210mm;
  }
}
