:root {
  color-scheme: light;
  --background: #e3cf9c;
  --panel: #f3e7c4;
  --panel-soft: #ecdcac;
  --line: #b6935c;
  --text: #3b2a18;
  --muted: #7a5f3d;
  --accent: #8c5e2a;
  --accent-strong: #b8860b;
  --user: #ddc48c;
  --assistant: #f6ecd2;
  --shadow: 0 20px 60px rgba(59, 40, 18, 0.28);
  --font-display: "Cinzel", Georgia, "Times New Roman", serif;
  --font-body: "EB Garamond", Georgia, "Times New Roman", serif;
  --font-sans: "Roboto", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(180deg, #faf3de 0%, #f7efd8 30%, #f0e2b8 65%, #e6cf9c 100%);
  color: var(--text);
  font-family: var(--font-body);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='matrix' values='0 0 0 0 0.15  0 0 0 0 0.1  0 0 0 0 0.05  0 0 0 0.35 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.5;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.chat-shell,
.admin-shell,
.auth-shell {
  position: relative;
  z-index: 1;
}

h1, h2, h3,
.chat-header h1,
.empty-state h2,
.brand-lockup,
.auth-card h2,
.admin-header h1 {
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

button,
input,
textarea {
  font: inherit;
}

.turbo-progress-bar {
  display: none;
}

.thinking-indicator {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
}

.thinking-dots {
  display: inline-flex;
  gap: 0.22rem;
}

.thinking-dots span {
  width: 0.32rem;
  height: 0.32rem;
  border-radius: 50%;
  background: var(--accent-strong);
  animation: thinking-pulse 1s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes thinking-pulse {
  0%, 80%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-0.22rem);
  }
}

.chat-shell {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
}

body.has-sidebar-open {
  overflow: hidden;
}

/* Mobile: sidebar as an off-canvas drawer */

.chat-sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  width: min(20rem, 86vw);
  padding: 1.25rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--line);
  background: var(--panel-soft);
  box-shadow: var(--shadow);
  visibility: hidden;
  transform: translateX(-100%);
  transition: transform 0.25s ease, visibility 0.25s ease;
}

.chat-shell.is-sidebar-open .chat-sidebar {
  visibility: visible;
  transform: translateX(0);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  border: 0;
  padding: 0;
  background: rgba(30, 22, 10, 0.55);
  opacity: 0;
  visibility: hidden;
  cursor: pointer;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.chat-shell.is-sidebar-open .sidebar-backdrop {
  opacity: 1;
  visibility: visible;
}

.sidebar-close {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

.sidebar-toggle {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  margin-right: auto;
  border: 1px solid rgba(59, 40, 18, 0.35);
  border-radius: 10px;
  background: rgba(253, 243, 221, 0.55);
  color: #3b2a18;
  cursor: pointer;
}

.sidebar-toggle-bars,
.sidebar-toggle-bars::before,
.sidebar-toggle-bars::after {
  display: block;
  width: 1.15rem;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.sidebar-toggle-bars {
  position: relative;
}

.sidebar-toggle-bars::before,
.sidebar-toggle-bars::after {
  position: absolute;
  left: 0;
  content: "";
}

.sidebar-toggle-bars::before {
  top: -0.4rem;
}

.sidebar-toggle-bars::after {
  top: 0.4rem;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

.chat-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  text-align: right;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid rgba(59, 40, 18, 0.4);
  background: linear-gradient(90deg, #f2e6c1, #dcbf85 18%, #dcbf85 100%);
  backdrop-filter: blur(18px);
}

.chat-header .eyebrow {
  color: rgba(59, 40, 18, 0.7);
  font-size: 0.8rem;
}

.chat-header h1 {
  color: #3b2a18;
}

.chat-header h1,
.empty-state h2 {
  margin: 0;
  letter-spacing: 0;
}

.chat-header h1 {
  font-size: 1.25rem;
}

.eyebrow,
.section-label,
.message-role {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.status-pill {
  flex: 0 0 auto;
  padding: 0.45rem 0.7rem;
  border: 1px solid rgba(184, 134, 11, 0.45);
  border-radius: 999px;
  color: #8a5a00;
  font-size: 0.78rem;
  white-space: nowrap;
}

.chat-header-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill-focus {
  border-color: rgba(140, 94, 42, 0.5);
  color: var(--accent);
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: min(100%, 840px);
  margin: 0 auto;
  padding: 1rem 0.85rem calc(7rem + env(safe-area-inset-bottom));
}

.conversation-end {
  height: 1px;
  scroll-margin-bottom: 6.5rem;
}

.empty-state {
  display: grid;
  align-content: start;
  gap: 0.8rem;
  padding-top: 0.5rem;
  text-align: center;
  font-family: var(--font-sans);
}

.empty-state h2 {
  max-width: 620px;
  margin: 0 auto;
  font-family: var(--font-sans);
  font-size: clamp(1.9rem, 9vw, 3.6rem);
  line-height: 1.05;
}

.empty-state-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.45;
}

.empty-state-question {
  font-size: 1.1rem;
  font-weight: 600;
}

.empty-state .eyebrow {
  font-size: 0.82rem;
  font-weight: 700;
}

.olympiad-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  justify-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.olympiad-picker form {
  display: contents;
}

.olympiad-button {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 7rem;
  aspect-ratio: 1;
  padding: 0.4rem;
  border: 2px solid #6e4c22;
  border-radius: 10px;
  background: #fdf8ec;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

@media (hover: hover) {
  .olympiad-button:hover {
    border-color: #5a3d1a;
    transform: translateY(-2px);
  }
}

.olympiad-button.is-selected {
  border-color: var(--accent-strong);
  box-shadow: var(--shadow), 0 0 0 4px rgba(184, 134, 11, 0.35);
  transform: translateY(-3px) scale(1.05);
}

.olympiad-button.is-selected:hover {
  border-color: var(--accent-strong);
}

.olympiad-button img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  padding: 0.4rem;
}

.olympiad-toast {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid rgba(140, 94, 42, 0.45);
  box-shadow: var(--shadow);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.4;
  backdrop-filter: blur(18px);
  animation: toast-in 0.25s ease;
}

.olympiad-toast-error {
  border-color: rgba(178, 34, 34, 0.45);
  background: rgba(178, 34, 34, 0.08);
  color: #8c1c1c;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  gap: 0.6rem;
}

.message-avatar {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  overflow: hidden;
  border: 3px solid #6e4c22;
  border-radius: 50%;
  background: #f8f2e0;
  color: var(--accent-strong);
  font-weight: 700;
}

.message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0.1rem;
}

.message-body {
  min-width: 0;
  padding: 0.75rem 0.85rem;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--assistant);
  box-shadow: var(--shadow);
}

.message-body p:last-child {
  margin-bottom: 0;
}

.message-body p {
  line-height: 1.55;
}

.is-user .message-body {
  background: var(--user);
}

.is-pending .message-body {
  color: var(--muted);
}


.composer-dock {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(100% - 1rem, 840px);
  margin: 0 auto calc(0.5rem + env(safe-area-inset-bottom));
}

.composer {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.composer textarea {
  min-height: 2.75rem;
  max-height: 8rem;
  padding: 0.5rem 0.4rem;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.4;
}

.composer textarea::placeholder {
  color: var(--muted);
}

.composer.is-disabled {
  cursor: help;
  opacity: 0.72;
}

.composer.is-disabled::before {
  position: absolute;
  right: 0.55rem;
  bottom: calc(100% + 0.55rem);
  max-width: min(22rem, calc(100vw - 2rem));
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(184, 134, 11, 0.45);
  border-radius: 8px;
  background: #f3e7c4;
  color: var(--text);
  content: attr(data-tooltip);
  font-size: 0.82rem;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.25rem);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.composer.is-disabled:hover::before {
  opacity: 1;
  transform: translateY(0);
}

.composer textarea:disabled,
.send-button:disabled {
  cursor: not-allowed;
}

.composer textarea:disabled {
  color: var(--muted);
}

.send-button:disabled {
  background: #d6c69a;
  color: #92795a;
}

.send-button,
.nav-item {
  border-radius: 8px;
  text-decoration: none;
}

.send-button {
  align-self: end;
  min-height: 2.75rem;
  border: 0;
  padding: 0 0.9rem;
  background: var(--accent);
  color: #fdf3dd;
  font-weight: 700;
  cursor: pointer;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 1.08rem;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.9rem;
  height: 2.9rem;
  overflow: hidden;
  border: 3px solid #6e4c22;
  border-radius: 50%;
  background: #f8f2e0;
  color: #3b2a18;
}

.chat-sidebar .brand-mark {
  width: 3.75rem;
  height: 3.75rem;
}

.chat-sidebar .brand-lockup {
  position: relative;
  padding-right: 2.5rem;
  font-size: 1.5rem;
}

button.brand-mark {
  padding: 0;
  appearance: none;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

button.brand-mark:hover {
  border-color: #5a3d1a;
  transform: translateY(-1px);
}

.credits-modal {
  position: relative;
  width: min(92vw, 34rem);
  max-height: 85dvh;
  overflow-y: auto;
  padding: 2.5rem 1.25rem 1.75rem;
  border: 3px solid #6e4c22;
  border-radius: 16px;
  background: linear-gradient(180deg, #faf3de, #f0e2b8);
  box-shadow: var(--shadow);
  color: var(--text);
}

.credits-modal::backdrop {
  background: rgba(30, 22, 10, 0.55);
  backdrop-filter: blur(3px);
}

.credits-modal-close {
  position: absolute;
  top: 0.3rem;
  right: 0.4rem;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.credits-modal-close:hover {
  color: var(--text);
}

.credits-modal-content {
  display: grid;
  gap: 0.5rem;
  text-align: center;
  justify-items: center;
}

.credits-modal-logo {
  width: min(11rem, 45vw);
  height: auto;
  aspect-ratio: 1;
  margin-bottom: 0.5rem;
  object-fit: contain;
}

.credits-modal-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.credits-modal-version {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.credits-modal-copyright {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.credits-modal-copyright a {
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.credits-modal-copyright a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0.1rem;
}

.sidebar-nav {
  display: grid;
  gap: 0.35rem;
  margin-top: 1.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.7rem 0.85rem;
  color: var(--muted);
  line-height: 1.3;
}

.nav-item.is-active,
.nav-item:hover {
  background: var(--panel-soft);
  color: var(--text);
}

.nav-item.new-conversation-button {
  background: #d4bc8a;
  color: var(--text);
  border-radius: 0.5rem;
  font-weight: 500;
  text-align: left;
  transition: background 0.2s ease;
}

.nav-item.new-conversation-button:hover {
  background: #c9af7a;
  color: var(--text);
}

.sidebar-section {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.sidebar-section-compact {
  margin-top: 1rem;
  padding-top: 0.5rem;
}

.conversation-title,
.previous-conversations-empty {
  margin: 0.35rem 0 0;
  color: var(--text);
  line-height: 1.4;
}

.previous-conversations {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.external-links {
  display: grid;
  gap: 0.05rem;
  margin-top: 0.25rem;
}

.previous-conversation {
  display: block;
  min-height: 2.5rem;
  padding: 0.65rem;
  overflow: hidden;
  border-radius: 8px;
  color: var(--text);
  line-height: 1.35;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.previous-conversation:hover {
  background: var(--panel-soft);
}

.previous-conversations-empty {
  color: var(--muted);
}

@media (min-width: 560px) {
  .olympiad-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
  }

  .olympiad-button {
    padding: 0.65rem;
    border-width: 3px;
    max-width: 8.5rem;
    border-radius: 12px;
  }

  .empty-state-subtitle {
    font-size: 1.15rem;
  }

  .empty-state-question {
    font-size: 1.25rem;
  }

  .empty-state .eyebrow {
    font-size: 0.95rem;
  }

  .message {
    grid-template-columns: 3.25rem minmax(0, 1fr);
    gap: 0.75rem;
  }

  .message-avatar {
    width: 3.25rem;
    height: 3.25rem;
  }

  .message-body {
    padding: 0.9rem 1rem;
  }

  .chat-header h1 {
    font-size: 1.5rem;
  }

  .chat-header .eyebrow {
    font-size: 0.92rem;
  }

  .credits-modal {
    padding: 2.5rem 2.25rem 2.25rem;
  }
}

@media (min-width: 880px) {
  .chat-shell {
    grid-template-columns: 18rem minmax(0, 1fr);
  }

  .chat-sidebar {
    position: sticky;
    top: 0;
    bottom: auto;
    z-index: auto;
    width: auto;
    height: 100vh;
    height: 100dvh;
    padding: 1.25rem;
    box-shadow: none;
    visibility: visible;
    transform: none;
    transition: none;
  }

  .sidebar-backdrop,
  .sidebar-close,
  .sidebar-toggle {
    display: none;
  }

  .chat-header {
    padding: 1.15rem 2rem;
  }

  .message-list {
    padding: 2rem 1rem 7rem;
  }

  .empty-state {
    align-content: center;
    min-height: 55dvh;
    padding-top: 0;
  }

  .composer textarea {
    resize: vertical;
    max-height: 11rem;
  }

  .olympiad-picker {
    display: flex;
    flex-wrap: wrap;
  }

  .olympiad-button {
    width: 9.5rem;
    max-width: 9.5rem;
    aspect-ratio: auto;
    height: 9.5rem;
    padding: 1rem;
  }

  .composer-dock {
    left: 18rem;
    width: min(calc(100% - 21rem), 840px);
  }

  .olympiad-toast {
    font-size: 1.15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-sidebar,
  .sidebar-backdrop {
    transition: none;
  }
}

/* Admin panel */

.admin-shell {
  display: grid;
  min-height: 100vh;
}

.admin-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  min-height: 100vh;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid rgba(59, 40, 18, 0.16);
  background: rgba(243, 231, 196, 0.86);
  backdrop-filter: blur(18px);
}

.admin-header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.admin-main {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.admin-flash {
  margin-bottom: 1.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(140, 94, 42, 0.35);
  border-radius: 8px;
  background: rgba(140, 94, 42, 0.1);
  color: var(--text);
  font-size: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:hover {
  background: var(--line);
  border-color: rgba(59, 40, 18, 0.3);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  border-color: transparent;
  background: var(--accent);
  color: #fdf3dd;
}

.btn-primary:hover {
  background: #6f4a20;
}

.btn-danger {
  border-color: rgba(140, 47, 28, 0.4);
  background: transparent;
  color: #8c2f1c;
}

.btn-danger:hover {
  background: rgba(140, 47, 28, 0.12);
  border-color: rgba(140, 47, 28, 0.6);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--panel-soft);
  color: var(--text);
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.doc-grid {
  display: grid;
  gap: 0.85rem;
}

.doc-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.doc-card:hover {
  border-color: rgba(140, 94, 42, 0.45);
}

.doc-card-main {
  min-width: 0;
}

.doc-card-title {
  display: block;
  margin: 0 0 0.3rem;
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 700;
  text-decoration: none;
}

.doc-card-title:hover {
  color: var(--accent);
}

.doc-card-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.doc-card-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
}

.doc-card-actions form {
  display: inline;
}

.admin-empty {
  display: grid;
  place-items: center;
  gap: 0.9rem;
  min-height: 40vh;
  padding: 2rem;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--panel);
}

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

.admin-form {
  display: grid;
  gap: 1.1rem;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.form-field {
  display: grid;
  gap: 0.4rem;
}

.form-field label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="password"],
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  line-height: 1.5;
  outline: 0;
  transition: border-color 0.15s ease;
}

.form-field select {
  cursor: pointer;
  font-size: 1rem;
  padding: 0.7rem 0.85rem;
  min-height: 2.4rem;
}

.form-field input[type="text"]:focus,
.form-field input[type="email"]:focus,
.form-field input[type="password"]:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--accent);
}

.form-field textarea {
  min-height: 22rem;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88rem;
}

.form-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.form-errors {
  padding: 0.85rem 1rem;
  border: 1px solid rgba(140, 47, 28, 0.4);
  border-radius: 8px;
  background: rgba(140, 47, 28, 0.08);
  color: #8c2f1c;
  font-size: 0.85rem;
}

.form-errors p {
  margin: 0 0 0.4rem;
  font-weight: 700;
}

.form-errors ul {
  margin: 0;
  padding-left: 1.1rem;
}

.doc-view {
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.doc-view-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 0 0 1.25rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

.doc-view-body {
  line-height: 1.7;
  color: var(--text);
}

.doc-view-body p {
  margin: 0 0 1rem;
}

.doc-view-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

/* Auth (Devise) */

.auth-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 24rem;
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-card .brand-lockup {
  justify-content: center;
  margin-bottom: 1.5rem;
}

.auth-card h2 {
  margin: 0 0 1.5rem;
  font-size: 1.35rem;
  text-align: center;
}

.auth-card .form-field {
  margin-bottom: 1.1rem;
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.auth-remember label {
  margin: 0;
  color: var(--muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
}

.auth-card .btn {
  width: 100%;
}

.auth-links {
  display: grid;
  gap: 0.4rem;
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  text-align: center;
}

.auth-links a {
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.auth-links a:hover {
  color: var(--accent);
}
