:root {
  --bg: #f2efe8;
  --bg-accent: #ddd3c3;
  --card: rgba(255, 252, 246, 0.88);
  --card-strong: #fffdf9;
  --line: rgba(72, 53, 35, 0.12);
  --text: #24180f;
  --muted: #6c5d51;
  --accent: #1f5f52;
  --accent-strong: #17483e;
  --accent-soft: rgba(31, 95, 82, 0.12);
  --danger: #8f3b34;
  --shadow: 0 22px 60px rgba(40, 28, 18, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Trebuchet MS", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.85), transparent 32%),
    linear-gradient(135deg, var(--bg) 0%, #ece6dd 45%, var(--bg-accent) 100%);
  min-height: 100vh;
  overflow-y: scroll;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.2) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.16) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent 85%);
  pointer-events: none;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1360px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(18px);
}

.auth-panel {
  width: min(760px, 100%);
  margin: 7vh auto 0;
  padding: 56px 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.workspace-top {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.workspace-topline {
  display: flex;
  justify-content: stretch;
  align-items: center;
  gap: 16px;
}

.workspace-nav-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: nowrap;
}

.workspace-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex: 0 0 auto;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  transition: min-height 0.18s ease;
}

.content-panel {
  display: none;
  padding: 28px;
}

.content-panel.active {
  display: block;
}

.eyebrow {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(2.2rem, 4vw, 4.4rem);
  max-width: 12ch;
}

h2 {
  font-size: 1.9rem;
}

h3 {
  font-size: 1.6rem;
}

.lead,
.muted,
.hint {
  color: var(--muted);
}

.lead {
  font-size: 1.05rem;
  line-height: 1.7;
  max-width: 60ch;
}

.auth-panel h1 {
  max-width: 10ch;
  margin: 0 auto;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: clamp(3.5rem, 7vw, 6.2rem);
  font-weight: 900;
  letter-spacing: -0.07em;
  line-height: 0.88;
  text-wrap: balance;
}

.auth-panel .lead {
  max-width: 33rem;
  margin: 18px auto 0;
  font-size: 1.08rem;
  line-height: 1.6;
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-panel .stack-lg {
  width: min(460px, 100%);
  margin-top: 24px;
  gap: 16px;
}

.auth-panel .field span {
  text-align: left;
}

.auth-panel .button-primary {
  width: 100%;
}

.auth-panel .hint {
  min-height: 1.3rem;
  margin: 2px 0 0;
}

.auth-panel .hint.hint-error {
  color: var(--danger);
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field span {
  font-size: 0.92rem;
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid rgba(76, 57, 41, 0.14);
  background: rgba(255, 255, 255, 0.72);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  outline: none;
  color: var(--text);
  font: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.field-control-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.field-control-row input {
  flex: 1 1 auto;
}

.field-control-row .icon-button {
  width: 48px;
  min-width: 48px;
  height: auto;
}

.field-control-row .icon-button svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(31, 95, 82, 0.5);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

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

.button {
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  color: #f6f5ef;
  background: linear-gradient(135deg, var(--accent) 0%, #0f3e35 100%);
  box-shadow: 0 16px 28px rgba(25, 78, 67, 0.22);
}

.button-secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  text-decoration: none;
}

.menu {
  display: flex;
  gap: 10px;
}

.menu-link {
  padding: 14px 16px;
  border-radius: 999px;
  border: 1px solid rgba(76, 57, 41, 0.1);
  background: rgba(255, 255, 255, 0.52);
  text-align: center;
  font: inherit;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.menu-link.active {
  background: linear-gradient(135deg, #2a6e60 0%, #1b564a 100%);
  border-color: transparent;
  color: #f6f5ef;
  box-shadow: 0 10px 20px rgba(27, 86, 74, 0.14);
}

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

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: baseline;
  margin-bottom: 24px;
}

.section-heading .muted {
  margin: 0;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 24px;
}

.action-row-left {
  grid-column: 1 / -1;
  justify-content: flex-start;
}

.preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  font-size: 0.9rem;
  color: var(--muted);
}

.preview-doc {
  min-height: 360px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: none;
  overflow: visible;
}


.menu-top {
  flex: 0 1 auto;
  flex-wrap: wrap;
  align-items: center;
  padding-top: 0;
}

.button-logout {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #7d2f2a;
  background: rgba(255, 248, 247, 0.95);
  border: 1px solid rgba(179, 71, 61, 0.28);
  white-space: nowrap;
  flex: 0 0 auto;
}

.button-logout:hover {
  box-shadow: 0 10px 20px rgba(179, 71, 61, 0.12);
}

.button-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
}

.button-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.preview-empty {
  margin: 0;
  color: var(--muted);
}

.preview-loading {
  min-height: 280px;
  display: grid;
  place-items: center;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}

.word-preview-frame {
  width: 100%;
  min-height: 1200px;
  margin: 0 auto;
  display: block;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.hidden {
  display: none;
}

html[data-session-state="workspace"] #loginCard {
  display: none;
}

html[data-session-state="workspace"] #workspace {
  display: flex;
}

html[data-session-state="pending"] #loginCard {
  display: none;
}

html[data-session-state="pending"] #workspace {
  display: none;
}

html[data-session-state="login"] #workspace {
  display: none;
}

.measuring-panel {
  display: block !important;
  position: absolute !important;
  visibility: hidden !important;
  pointer-events: none !important;
  left: -99999px !important;
  top: 0 !important;
  width: min(1360px, calc(100vw - 32px)) !important;
}

.admin-shell {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.admin-header {
  padding: 32px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
}

.admin-layout {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 20px;
}

.admin-layout .card {
  padding: 28px;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-row {
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.user-row strong {
  display: block;
  font-size: 1rem;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-badge {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.icon-button:hover {
  transform: translateY(-1px);
}

.icon-button svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.icon-button-danger {
  color: var(--danger);
  border-color: rgba(143, 59, 52, 0.22);
}

.icon-button-danger:hover {
  box-shadow: 0 10px 20px rgba(143, 59, 52, 0.12);
}

.status-active {
  color: #165548;
  background: rgba(22, 85, 72, 0.12);
}

.status-disabled {
  color: var(--danger);
  background: rgba(143, 59, 52, 0.12);
}

@media (max-width: 1080px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, 100%);
    padding: 18px 0 36px;
  }

  .auth-panel,
  .content-panel,
  .workspace-top,
  .admin-header,
  .admin-layout .card {
    padding: 22px;
    border-radius: 22px;
  }

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

  .section-heading,
  .admin-header,
  .workspace-top,
  .workspace-topline {
    align-items: start;
    flex-direction: column;
  }

  .workspace-nav-row {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .workspace-actions {
    width: 100%;
    justify-content: space-between;
  }

  .menu-top {
    width: 100%;
    overflow-x: visible;
    flex-direction: column;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .menu-link {
    width: 100%;
    flex: 0 0 auto;
    min-width: 100%;
    font-size: 0.92rem;
    white-space: normal;
  }
}
