/* Experientzia Admin: warm, calm and practical. Palette from the logo. */

:root {
  --bg: #FBF6EE;
  --surface: #FFFFFF;
  --surface-warm: #FFFCF8;
  --surface-muted: #F6EEE2;
  --ink: #2F4145;
  --muted: #6F6355;
  --border: #E8DCC8;
  --border-strong: #D5C3A7;
  --primary: #B04F2B;
  --primary-hover: #8A3C1E;
  --primary-tint: #F6E4D9;
  --secondary: #2C5A61;
  --secondary-hover: #21454B;
  --success: #2C5A61;
  --success-bg: #E6F0EF;
  --danger: #A63D40;
  --danger-hover: #87302F;
  --danger-bg: #F8E7E5;
  --warning-text: #7A4E0F;
  --warning-bg: #FCF1DF;
  --terracotta: #B04F2B;
  --gold: #D48A36;
  --teal: #2C5A61;
  --plum: #5E3050;
  --focus: #2C5A61;
  --radius: 10px;
  --radius-small: 7px;
  --shadow: 0 1px 2px rgba(47, 65, 69, 0.05), 0 4px 14px rgba(47, 65, 69, 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
}

img { max-width: 100%; height: auto; }

a { color: var(--secondary); text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }

h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--ink); }
p { margin: 0; }
code { font-family: var(--mono); font-size: 0.9em; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 1000;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-small);
  background: var(--ink);
  color: #fff;
  font-weight: 600;
}
.skip-link:focus { top: 1rem; color: #fff; }

/* App shell */

.shell {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 1.25rem 0.9rem 2rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0.35rem 1.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}
.brand:hover { color: var(--ink); }
.brand__mark { width: 36px; height: 36px; border-radius: 50%; }
.brand__suffix { color: var(--primary); font-weight: 600; }

.menu-button {
  display: none;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.5rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.menu-button__icon,
.menu-button__icon::before,
.menu-button__icon::after {
  display: block;
  width: 1.1rem;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.menu-button__icon { position: relative; }
.menu-button__icon::before,
.menu-button__icon::after { content: ""; position: absolute; left: 0; }
.menu-button__icon::before { top: -6px; }
.menu-button__icon::after { top: 6px; }

.nav__heading {
  margin: 1.1rem 0.75rem 0.35rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav__list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }

.nav__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}
.nav__link:hover { background: var(--surface-muted); color: var(--ink); }
.nav__link[aria-current="page"] {
  background: var(--primary-tint);
  color: var(--primary-hover);
  font-weight: 650;
  box-shadow: inset 3px 0 0 var(--primary);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
}

.content { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.7rem 2rem;
  background: rgba(251, 246, 238, 0.94);
  border-bottom: 1px solid var(--border);
}
.topbar__link { font-weight: 600; text-decoration: none; }
.topbar__spacer { flex: 1; }
.topbar__user { color: var(--muted); text-decoration: none; overflow-wrap: anywhere; }
.topbar__user:hover, .topbar__user[aria-current="page"] { color: var(--ink); text-decoration: underline; }
.topbar__signout { margin: 0; }

.main { width: 100%; max-width: 1200px; margin: 0 auto; padding: 2rem 2rem 4rem; }
.main:focus { outline: none; }

.page-header { margin-bottom: 1.5rem; }
.page-header__title { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.01em; }
.page-header__lead { max-width: 65ch; margin-top: 0.35rem; color: var(--muted); }

@media (max-width: 900px) {
  .shell { display: block; }
  .sidebar {
    top: 0;
    z-index: 30;
    height: auto;
    padding: 0.55rem 1rem;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .sidebar__head { margin: 0; }
  .menu-button { display: inline-flex; }
  .nav { display: none; max-height: calc(100vh - 4rem); overflow-y: auto; padding: 0.25rem 0 0.75rem; }
  .sidebar[data-open] .nav { display: block; }
  .topbar { position: static; padding: 0.55rem 1rem; }
  .main { padding: 1.25rem 1rem 3rem; }
  .page-header__title { font-size: 1.5rem; }
}

@media (max-width: 600px) {
  body { font-size: 15px; }
}

/* Layout helpers */

.stack { display: grid; gap: 1rem; }
.stack--small { gap: 0.5rem; }
.stack--large { gap: 1.5rem; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.cluster--end { justify-content: flex-end; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.button:disabled { opacity: 0.55; cursor: not-allowed; }
.button--primary { background: var(--primary); color: #fff; }
.button--primary:hover:not(:disabled) { background: var(--primary-hover); color: #fff; }
.button--secondary { background: var(--secondary); color: #fff; }
.button--secondary:hover:not(:disabled) { background: var(--secondary-hover); color: #fff; }
.button--outline { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.button--outline:hover:not(:disabled) { border-color: var(--secondary); color: var(--secondary); }
.button--quiet { background: transparent; color: var(--ink); border-color: var(--border); }
.button--quiet:hover:not(:disabled) { background: var(--surface); color: var(--ink); }
.button--danger { background: var(--danger); color: #fff; }
.button--danger:hover:not(:disabled) { background: var(--danger-hover); color: #fff; }
.button--danger-outline { background: var(--surface); color: var(--danger); border-color: #E3BFBC; }
.button--danger-outline:hover:not(:disabled) { background: var(--danger-bg); color: var(--danger-hover); }
.button--small { min-height: 2.1rem; padding: 0.3rem 0.7rem; font-size: 0.9rem; }
.button--block { width: 100%; }
.button--link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--secondary);
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.button--link:hover:not(:disabled) { color: var(--primary-hover); }

/* Forms */

.field { display: grid; gap: 0.35rem; align-content: start; }
.field__label { font-weight: 600; }
.field__help { color: var(--muted); font-size: 0.9rem; }
.field__message { font-size: 0.9rem; font-weight: 600; }
.field__message--error { color: var(--danger); }
.field__message--warning { color: var(--warning-text); }

.input, .textarea, .select {
  width: 100%;
  min-height: 2.6rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.textarea { min-height: 5.5rem; line-height: 1.5; resize: vertical; }
.textarea--code { font-family: var(--mono); font-size: 0.92rem; }
.input:hover, .textarea:hover, .select:hover { border-color: #C6AF8E; }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(44, 90, 97, 0.28);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"] {
  border-color: var(--danger);
  background: #FFFBFA;
}
.is-missing .input, .is-missing .textarea { border-color: var(--gold); background: #FFFCF5; }

.checkbox { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 500; cursor: pointer; }
.checkbox input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--primary); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 0.55rem; font-size: 0.9rem; font-weight: 600; cursor: pointer; }
.switch__input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track {
  position: relative;
  flex-shrink: 0;
  width: 2.5rem;
  height: 1.45rem;
  border-radius: 999px;
  background: #D6C8B2;
  transition: background-color 0.15s;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(1.45rem - 6px);
  height: calc(1.45rem - 6px);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}
.switch__input:checked + .switch__track { background: var(--secondary); }
.switch__input:checked + .switch__track::after { transform: translateX(1.05rem); }
.switch__input:focus-visible + .switch__track { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch__input:disabled + .switch__track { opacity: 0.6; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: 1rem; }

/* Cards, alerts, status */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.card__title { font-size: 1.15rem; font-weight: 650; }
.card__lead { margin-top: 0.2rem; color: var(--muted); font-size: 0.92rem; }
.card__body { padding: 1.1rem 1.25rem; }
.card__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface-warm);
}
.card__footer-note { margin-right: auto; color: var(--muted); font-size: 0.9rem; }

.alert { padding: 0.8rem 1rem; border: 1px solid; border-radius: 8px; }
.alert--error { background: var(--danger-bg); border-color: #E9C4C1; color: #7E2B2E; }
.alert--warning { background: var(--warning-bg); border-color: #EFD3A6; color: #6A440E; }
.alert--success { background: var(--success-bg); border-color: #C3DAD7; color: #1F4449; }
.alert--info { background: #EFF4F3; border-color: #D0DFDD; color: var(--ink); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.1rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
  white-space: nowrap;
}
.pill--warning { background: var(--warning-bg); border-color: #EFD3A6; color: #6A440E; }
.pill--success { background: var(--success-bg); border-color: #C3DAD7; color: #1F4449; }
.pill--primary { background: var(--primary-tint); border-color: #EBC7B3; color: var(--primary-hover); }

.lang-tag {
  display: inline-block;
  padding: 0.08rem 0.36rem;
  border-radius: 4px;
  background: var(--secondary);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.35;
}
.lang-tag--en { background: var(--plum); }

.loading { display: flex; align-items: center; gap: 0.6rem; padding: 1rem 0; color: var(--muted); }
.spinner {
  display: inline-block;
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.button .spinner { width: 0.95rem; height: 0.95rem; border-color: rgba(255, 255, 255, 0.45); border-top-color: #fff; }
.button--outline .spinner, .button--quiet .spinner { border-color: var(--border-strong); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  padding: 1.5rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  text-align: center;
}

/* Toasts and dialogs */

.toasts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 100;
  display: grid;
  gap: 0.5rem;
  width: min(24rem, calc(100vw - 2rem));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem 0.75rem 1rem;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 8px 28px rgba(47, 65, 69, 0.25);
}
.toast--success { background: var(--secondary); }
.toast--error { background: var(--danger); }
.toast__text { flex: 1; }
.toast__close {
  padding: 0 0.25rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.dialog {
  width: min(30rem, calc(100vw - 2rem));
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  color: var(--ink);
  box-shadow: 0 24px 64px rgba(47, 65, 69, 0.32);
}
.dialog::backdrop { background: rgba(47, 65, 69, 0.45); }
.dialog__body { display: grid; gap: 0.6rem; padding: 1.4rem 1.5rem 0.75rem; }
.dialog__title { font-size: 1.2rem; }
.dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.6rem; padding: 1rem 1.5rem 1.35rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .spinner { animation-duration: 2.4s; }
}

/* Bilingual fields: Svenska and English side by side */

.loc-field { display: grid; gap: 0.5rem; padding: 1.1rem 0; border-top: 1px solid var(--border); }
.loc-field:first-child { padding-top: 0.25rem; border-top: 0; }
.loc-field__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.7rem; }
.loc-field__label { font-weight: 650; }
.loc-field__key {
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
}
.loc-field__actions { display: flex; gap: 0.75rem; margin-left: auto; }
.loc-field__cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem 1rem; }
.loc-field__col { display: grid; align-content: start; gap: 0.3rem; }
.loc-field__lang { display: flex; align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.loc-field__help { color: var(--muted); font-size: 0.9rem; }
.loc-field__hint { color: var(--muted); font-size: 0.82rem; }
.loc-field.is-changed > .loc-field__head .loc-field__label::after {
  content: "Changed";
  margin-left: 0.5rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--warning-bg);
  color: #6A440E;
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: 0.1em;
}

@media (max-width: 760px) {
  .loc-field__cols { grid-template-columns: 1fr; }
}

/* Texts page */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; }
.toolbar__search { flex: 1 1 18rem; max-width: 32rem; }

.texts-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: start; gap: 1.5rem; }
.group-nav { position: sticky; top: 4.25rem; display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.group-nav__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.95rem;
  text-decoration: none;
}
.group-nav__link:hover { background: var(--surface); color: var(--ink); }
.group-nav__link[aria-current="true"] { background: var(--surface); font-weight: 650; box-shadow: inset 3px 0 0 var(--primary); }
.dirty-dot { flex-shrink: 0; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--gold); }
.group-select { display: none; }
.text-group { scroll-margin-top: 5rem; }

@media (max-width: 1100px) {
  .texts-layout { grid-template-columns: 1fr; }
  .group-nav { display: none; }
  .group-select { display: block; flex: 1 1 14rem; }
}

/* Content lists */

.list-group { display: grid; gap: 0.75rem; }
.list-group + .list-group { margin-top: 2rem; }
.list-group__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 1rem; }
.list-group__title { font-size: 1.1rem; font-weight: 650; }

.item-list { display: grid; gap: 0.75rem; margin: 0; padding: 0; list-style: none; }
.item-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.item-card.is-editing { border-color: var(--border-strong); box-shadow: 0 0 0 3px rgba(176, 79, 43, 0.12), var(--shadow); }
.item-card__row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; padding: 0.9rem 1.1rem; }
.item-card__position { min-width: 1.6rem; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.item-card__titles { display: grid; flex: 1 1 16rem; gap: 0.2rem; min-width: 0; }
.item-card__title { display: flex; align-items: baseline; gap: 0.5rem; font-weight: 600; overflow-wrap: anywhere; }
.item-card__title--en { color: var(--muted); font-weight: 500; }
.item-card.is-hidden .item-card__titles { opacity: 0.7; }
.item-card__meta { color: var(--muted); font-size: 0.85rem; }
.item-card__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.item-card__editor { padding: 1.1rem; border-top: 1px solid var(--border); }
.item-card__editor-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; }

.swatch { flex-shrink: 0; width: 1.1rem; height: 1.1rem; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.swatch--terracotta { background: var(--terracotta); }
.swatch--gold { background: var(--gold); }
.swatch--teal { background: var(--teal); }
.swatch--plum { background: var(--plum); }

.choice-group { display: grid; gap: 0.45rem; margin: 0; padding: 0; border: 0; }
.choice-group legend { margin-bottom: 0.35rem; padding: 0; font-weight: 600; }
.choice-group__options { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.choice {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem 0.35rem 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.choice input { margin: 0; accent-color: var(--primary); }

/* Pages editor */

.url-preview { color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.url-preview code { padding: 0.05rem 0.35rem; border-radius: 4px; background: var(--surface-muted); color: var(--ink); }

.segmented { display: inline-flex; overflow: hidden; border: 1px solid var(--border-strong); border-radius: 7px; }
.segmented button {
  padding: 0.2rem 0.65rem;
  border: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--border-strong); }
.segmented button[aria-pressed="true"] { background: var(--secondary); color: #fff; }

.markdown-preview {
  min-height: 12rem;
  max-height: 36rem;
  overflow: auto;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-warm);
  overflow-wrap: anywhere;
}
.markdown-preview > :first-child { margin-top: 0; }
.markdown-preview h1, .markdown-preview h2 { margin: 1.1rem 0 0.4rem; font-size: 1.2rem; }
.markdown-preview h3, .markdown-preview h4 { margin: 0.9rem 0 0.35rem; font-size: 1.05rem; }
.markdown-preview p, .markdown-preview ul, .markdown-preview ol { margin: 0 0 0.7rem; }
.markdown-preview table { border-collapse: collapse; margin-bottom: 0.7rem; }
.markdown-preview th, .markdown-preview td { padding: 0.3rem 0.5rem; border: 1px solid var(--border); }

.cheatsheet { color: var(--muted); font-size: 0.9rem; }
.cheatsheet summary { color: var(--secondary); font-weight: 600; cursor: pointer; }
.cheatsheet dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 0.6rem 0 0; }
.cheatsheet dd { margin: 0; }

/* Images */

.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr)); gap: 1rem; }
.image-card { display: flex; flex-direction: column; }
.image-card__preview {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  max-width: 100%;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  background: repeating-linear-gradient(45deg, #F6EEE2 0 10px, #F1E6D6 10px 20px);
}
.image-card__preview img { width: 100%; height: 100%; object-fit: contain; }
.image-card__placeholder { max-width: 18rem; padding: 1rem; color: var(--muted); font-size: 0.92rem; text-align: center; }
.image-card__body { display: grid; flex: 1; align-content: start; gap: 0.9rem; padding: 1rem 1.1rem 1.1rem; }
.image-card__meta { color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.file-button { position: relative; }
.file-button input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-button:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.upload-progress { width: 100%; height: 0.5rem; accent-color: var(--primary); }

/* Messages */

.tabs { display: inline-flex; gap: 0.25rem; margin-bottom: 1rem; padding: 0.25rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-muted); }
.tabs button {
  padding: 0.4rem 0.9rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tabs button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.messages-layout { display: grid; grid-template-columns: minmax(17rem, 23rem) minmax(0, 1fr); align-items: start; gap: 1rem; }
.message-list { display: grid; margin: 0; padding: 0; list-style: none; }
.message-list li + li { border-top: 1px solid var(--border); }
.message-list__button {
  display: grid;
  gap: 0.15rem;
  width: 100%;
  padding: 0.8rem 1rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.message-list li:first-child .message-list__button { border-radius: var(--radius) var(--radius) 0 0; }
.message-list li:last-child .message-list__button { border-radius: 0 0 var(--radius) var(--radius); }
.message-list__button:hover { background: var(--surface-warm); }
.message-list__button[aria-current="true"] { background: var(--primary-tint); box-shadow: inset 3px 0 0 var(--primary); }
.message-list__top { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.message-list__name { font-weight: 500; overflow-wrap: anywhere; }
.message-list__date { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.message-list__preview { color: var(--muted); font-size: 0.88rem; overflow-wrap: anywhere; }
.is-unread .message-list__name { font-weight: 750; }
.unread-dot { display: inline-block; width: 0.5rem; height: 0.5rem; margin-right: 0.4rem; border-radius: 50%; background: var(--primary); vertical-align: 0.1em; }

.message-detail__meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.35rem 1rem; margin: 0; }
.message-detail__meta dt { color: var(--muted); font-weight: 600; }
.message-detail__meta dd { margin: 0; overflow-wrap: anywhere; }
.message-body {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-warm);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

/* Dashboard */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr)); gap: 1rem; }
.stat { display: grid; gap: 0.2rem; padding: 1.05rem 1.2rem; color: var(--ink); text-decoration: none; border-top: 4px solid var(--border); }
a.stat:hover { border-color: var(--border-strong); color: var(--ink); }
.stat--terracotta { border-top-color: var(--terracotta); }
.stat--gold { border-top-color: var(--gold); }
.stat--teal { border-top-color: var(--teal); }
.stat--plum { border-top-color: var(--plum); }
.stat__value { font-size: 2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__label { color: var(--muted); font-size: 0.92rem; font-weight: 600; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; margin-top: 1rem; }
.checklist { display: grid; gap: 0.75rem; margin: 0; padding: 0; list-style: none; }
.checklist li { display: flex; align-items: flex-start; gap: 0.7rem; }
.check-icon {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-top: 0.1rem;
  border-radius: 50%;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
}
.check-icon--ok { background: var(--secondary); }
.check-icon--warn { background: var(--gold); }
.link-list { display: grid; margin: 0; padding: 0; list-style: none; }
.link-list li + li { border-top: 1px solid var(--border); }
.link-list a { display: grid; gap: 0.1rem; padding: 0.65rem 0; color: var(--ink); text-decoration: none; }
.link-list a:hover .link-list__title { text-decoration: underline; }
.link-list__title { font-weight: 600; }

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

/* Tables */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th, .table td { padding: 0.7rem 1rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { background: var(--surface-warm); color: var(--muted); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.table__actions { text-align: right; white-space: nowrap; }

/* Sign-in and error pages */

.auth-page {
  display: flex;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, #F5DEC8 0, transparent 42%),
    radial-gradient(circle at 92% 92%, #DFEAE7 0, transparent 38%),
    var(--bg);
}
.auth-main { width: 100%; max-width: 27rem; margin: auto; padding: 2rem 1rem; }
.auth-card {
  display: grid;
  gap: 1rem;
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(47, 65, 69, 0.1);
}
.auth-card__brand { display: flex; align-items: center; gap: 0.8rem; }
.auth-card__brand img { width: 3.25rem; height: 3.25rem; border-radius: 50%; }
.auth-card__name { font-size: 1.1rem; font-weight: 700; }
.auth-card__title { font-size: 1.5rem; }
.auth-card__lead { color: var(--muted); }
.auth-card__note { color: var(--muted); font-size: 0.88rem; }

@media (max-width: 480px) {
  .auth-card { padding: 1.5rem 1.25rem; }
}
