:root {
  --bg: #f2eee7;
  --paper: rgba(255, 251, 245, 0.92);
  --paper-strong: #fffaf3;
  --ink: #1c1d1c;
  --muted: #61635d;
  --line: rgba(28, 29, 28, 0.12);
  --accent: #9f2f20;
  --accent-dark: #7b2418;
  --accent-2: #1e6c67;
  --chip: rgba(159, 47, 32, 0.09);
  --shadow: 0 22px 70px rgba(63, 41, 24, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at top left, rgba(159, 47, 32, 0.15), transparent 34%),
    radial-gradient(circle at top right, rgba(30, 108, 103, 0.12), transparent 28%),
    linear-gradient(180deg, #faf5ec 0%, var(--bg) 100%);
}

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

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0 28px;
}

.brand {
  display: grid;
  gap: 4px;
}

.brand-mark {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-subtitle {
  font-size: 0.84rem;
  color: var(--muted);
}

.nav {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.inline-form {
  margin: 0;
}

.link-button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.content {
  display: grid;
  gap: 24px;
}

.hero,
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 22px;
}

.hero {
  padding: 40px;
}

.panel {
  padding: 28px;
}

.hero-split {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.9fr);
}

.hero-stats,
.hero-callout {
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 20px;
}

.hero-stats {
  margin: 0;
  display: grid;
  gap: 16px;
  align-content: start;
}

.narrow {
  max-width: 480px;
}

.dashboard-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.workspace-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.result-panel {
  position: relative;
}

.panel-head,
.toolbar-row,
.status-strip,
.history-card-head,
.history-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.page-title {
  margin-bottom: 6px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-size: 0.75rem;
}

h1,
h2,
p,
ul,
dl {
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.96;
  margin-bottom: 12px;
}

h2 {
  font-size: 1.1rem;
  margin-bottom: 10px;
}

.muted {
  color: var(--muted);
}

.stacked-form,
.stacked-list {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
  font-size: 0.95rem;
}

.inline-fields {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

textarea,
select,
input[type="date"],
input[type="text"] {
  width: 100%;
  border: 1px solid rgba(28, 29, 28, 0.16);
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  color: var(--ink);
  background: var(--paper-strong);
}

textarea {
  min-height: 240px;
  resize: vertical;
  line-height: 1.5;
}

textarea:focus,
select:focus,
input[type="date"]:focus,
input[type="text"]:focus,
.primary-button:focus,
.ghost-button:focus,
.token-button:focus {
  outline: 2px solid rgba(30, 108, 103, 0.35);
  outline-offset: 2px;
}

.primary-button,
.ghost-button,
.token-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 12px 18px;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  color: #fff8f2;
  font-weight: 700;
  border: 0;
}

.primary-button:hover {
  background: var(--accent-dark);
}

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

.ghost-button:disabled,
.primary-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.metric {
  font-size: 2.2rem;
  margin-bottom: 6px;
}

.mono {
  font-family: "Courier New", monospace;
  font-size: 0.95rem;
  word-break: break-all;
}

.simple-list {
  padding-left: 18px;
  margin-bottom: 0;
}

.meta-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

dt {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 6px;
}

dd {
  margin: 0;
}

.balance-chip,
.meta-chip,
.translation-meta span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid rgba(159, 47, 32, 0.1);
}

.translation-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.translation-surface {
  min-height: 220px;
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed rgba(28, 29, 28, 0.2);
  background: rgba(255, 255, 255, 0.54);
  line-height: 1.8;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.token-button {
  min-height: 0;
  padding: 2px 4px;
  margin: 0 1px;
  border-radius: 10px;
  line-height: 1.3;
  vertical-align: baseline;
}

.token-button:hover {
  background: rgba(30, 108, 103, 0.12);
}

.token-button.is-selected {
  background: rgba(30, 108, 103, 0.18);
  border-color: rgba(30, 108, 103, 0.32);
}

.token-editor-panel {
  margin-top: 18px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  max-height: 32rem;
  overflow: auto;
}

.token-editor-panel h3 {
  margin: 0;
  font-size: 1rem;
}

.suggestion-list {
  display: grid;
  gap: 10px;
}

.suggestion-button {
  justify-content: flex-start;
  width: 100%;
  text-align: left;
  white-space: normal;
}

.version-item + .version-item {
  margin-top: 16px;
}

.inline-note {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(30, 108, 103, 0.08);
  border: 1px solid rgba(30, 108, 103, 0.14);
}

.text-link {
  color: var(--accent-2);
  font-weight: 700;
}

.history-card,
.placeholder-card {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
}

.history-card h2 {
  margin-bottom: 8px;
}

.history-card h2,
.history-card p,
.info-card p,
.token-history-card p,
.hero-callout p {
  overflow-wrap: anywhere;
}

.history-route {
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-size: 0.75rem;
}

.history-detail {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.detail-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.toolbar-row > .primary-button,
.toolbar-row > .ghost-button {
  flex: 0 1 auto;
}

.history-card-head {
  align-items: flex-start;
}

.history-detail {
  overflow-x: auto;
}

.compact-field {
  min-width: 180px;
}

.alert {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(159, 47, 32, 0.08);
  border: 1px solid rgba(159, 47, 32, 0.2);
}

.info-card {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
}

.metric-code {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  word-break: break-all;
}

.token-history-card h2 {
  margin-bottom: 4px;
}

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

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

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 1120px);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero,
  .panel {
    padding: 22px;
  }

  .hero-split,
  .workspace-grid,
  .inline-fields,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .nav {
    width: 100%;
    gap: 10px;
  }

  .nav > a,
  .nav > .balance-chip,
  .nav > .inline-form {
    width: 100%;
  }

  .nav > a,
  .nav > .balance-chip,
  .nav .link-button {
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.58);
    justify-content: center;
  }

  .nav .link-button {
    width: 100%;
  }

  .history-controls,
  .toolbar-row,
  .status-strip {
    align-items: stretch;
  }

  .history-controls > *,
  .toolbar-row > * {
    width: 100%;
  }

  .compact-field {
    min-width: 0;
  }

  .translation-surface {
    min-height: 180px;
    padding: 14px;
    font-size: 1rem;
  }

  .token-button {
    margin: 2px 1px;
    padding: 4px 6px;
  }

  .token-editor-panel .panel-head {
    align-items: stretch;
  }

  .token-editor-panel {
    margin-top: 14px;
    padding: 16px;
    position: sticky;
    bottom: 12px;
    max-height: min(70vh, 34rem);
    box-shadow: 0 18px 40px rgba(63, 41, 24, 0.16);
  }

  .suggestion-list {
    max-height: 32vh;
    overflow: auto;
  }
}
