/* nook – ruhiges, helles Farbschema mit dunkelgrünen Akzenten. */

:root {
  --bg: #f5f8f5;
  --surface: #ffffff;
  --surface-muted: #f0f4f0;
  --ink: #16211c;
  --muted: #5d6d64;
  --line: #dde5df;
  --accent: #2f6f4e;
  --accent-dark: #235640;
  --accent-soft: #e7f1ea;
  --danger: #a3341f;
  --danger-soft: #fbeeeb;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(22, 33, 28, .05), 0 8px 24px rgba(22, 33, 28, .06);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
}

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

/* Muss die display-Regeln der Komponenten überstimmen. */
[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 {
  font-weight: 650;
  line-height: 1.25;
  margin: 0;
}

a {
  color: var(--accent-dark);
}

.shell {
  width: 100%;
  max-width: 1140px;
  margin-inline: auto;
  padding-inline: 20px;
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
  z-index: 60;
  background: var(--surface);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

/* ------------------------------------------------------------- masthead */

.masthead {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  flex-wrap: wrap;
  padding-block: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand__logo {
  display: block;
  border-radius: 11px;
}

.brand__text {
  display: flex;
  flex-direction: column;
}

.brand__name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--accent-dark);
}

.brand__claim {
  font-size: 12.5px;
  color: var(--muted);
}

.masthead__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--surface-muted);
  color: var(--muted);
  white-space: nowrap;
}

.badge--admin {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.badge--bot {
  color: #fff;
}

.badge__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: .85;
}

/* -------------------------------------------------------------- buttons */

.button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-muted);
  color: var(--ink);
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  white-space: nowrap;
}

.button:hover {
  background: #e6ece7;
}

a.button {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.button--primary {
  background: var(--accent);
  color: #fff;
}

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

.button--ghost {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.button--ghost:hover {
  background: #d9e8df;
}

.button--quiet {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.button--quiet:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.button--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.button--danger:hover {
  background: #f6ded8;
}

.button--small {
  padding: 6px 11px;
  font-size: 13.5px;
}

.button[disabled] {
  opacity: .55;
  cursor: not-allowed;
}

:where(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ----------------------------------------------------------------- tabs */

.tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.tabs__inner {
  display: flex;
  gap: 6px;
}

.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 13px 4px;
  margin-right: 20px;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.tab.is-active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
}

.tab__count {
  display: inline-block;
  min-width: 22px;
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-muted);
  font-size: 12px;
  color: var(--muted);
}

.tab.is-active .tab__count {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

/* -------------------------------------------------------------- filters */

main {
  flex: 1;
  padding-block: 26px 48px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(140px, 1fr)) auto;
  gap: 14px;
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field__label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.field__hint {
  font-size: 12.5px;
  color: var(--muted);
}

.field__error,
.picker__error {
  font-size: 12.5px;
  color: var(--danger);
  font-weight: 600;
  margin: 0;
}

/* Auswahlfeld mit eingebettetem Formular zum Anlegen einer neuen Gruppe. */
.picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.picker__creator {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  padding: 8px;
}

.picker__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.picker__actions .input--color {
  width: 44px;
  height: 34px;
  flex: none;
}

.input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 9px 11px;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
}

textarea.input {
  min-height: 150px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.5;
}

.input--color {
  padding: 3px;
  height: 40px;
  width: 56px;
}

.filters__reset {
  display: flex;
  align-items: end;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-block: 22px 14px;
  flex-wrap: wrap;
}

.toolbar__summary {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* ---------------------------------------------------------------- cards */

.groups {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.group__heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}

.group__title {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--accent-dark);
}

.group__count {
  font-size: 13px;
  color: var(--muted);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card__title {
  font-size: 17px;
  word-break: break-word;
}

.card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card__body {
  margin: 0;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 168px;
  overflow: hidden;
  position: relative;
}

.card__body.is-expanded {
  max-height: none;
}

.card__body:not(.is-expanded).is-clipped::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 46px;
  background: linear-gradient(to bottom, rgba(240, 244, 240, 0), var(--surface-muted));
}

.card__toggle {
  align-self: flex-start;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent-dark);
  cursor: pointer;
  text-decoration: underline;
}

.card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}

.card__actions--admin {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.drag-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: grab;
}

.drag-link:hover {
  background: var(--accent-dark);
}

.drag-hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

/* ------------------------------------------------------ Anmeldemaske */

.gate {
  display: flex;
  justify-content: center;
  padding-block: 6vh 4vh;
}

.gate__card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  text-align: center;
}

.gate__logo {
  border-radius: 15px;
  margin-bottom: 14px;
}

.gate__title {
  font-size: 26px;
  letter-spacing: -.02em;
  color: var(--accent-dark);
}

.gate__claim {
  margin: 6px 0 22px;
  color: var(--muted);
  font-size: 14.5px;
}

.gate .form {
  text-align: left;
}

.form__actions--full {
  justify-content: stretch;
}

.form__actions--full .button {
  width: 100%;
  justify-content: center;
}

.empty {
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 46px 20px;
}

/* --------------------------------------------------------------- footer */

.footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding-block: 18px;
  color: var(--muted);
  font-size: 13.5px;
}

.footer p {
  margin: 0;
}

/* ---------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 16px;
  overflow-y: auto;
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 33, 28, .45);
}

.modal__dialog {
  position: relative;
  width: 100%;
  max-width: 620px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(22, 33, 28, .25);
  overflow: hidden;
}

.modal__dialog--wide {
  max-width: 820px;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal__title {
  font-size: 18px;
}

.modal__close {
  appearance: none;
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
}

.modal__body {
  padding: 20px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.form__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
  flex-wrap: wrap;
}

.form__actions--split {
  justify-content: space-between;
}

.form__actions--start {
  justify-content: flex-start;
}

.form__error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
  font-weight: 600;
}

.notice__text {
  flex: 1;
  min-width: 180px;
}

/* ------------------------------------------------------- manage section */

.manage-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.manage-tab {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 13px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.manage-tab.is-active {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-dark);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.list__item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}

.list__name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  word-break: break-word;
}

.list__meta {
  font-size: 13px;
  color: var(--muted);
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(22, 33, 28, .12);
  flex: none;
}

.section-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 10px;
}

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

.inline-form {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
}

.inline-form .field {
  flex: 1;
  min-width: 160px;
}

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 70;
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  max-width: min(90vw, 520px);
  text-align: center;
}

.toast[hidden] {
  display: none;
}

.toast--error {
  background: var(--danger);
}

/* ----------------------------------------------------------- responsive */

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

  .filters__reset {
    grid-column: 1 / -1;
  }
}

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

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

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

  .masthead__inner {
    min-height: auto;
  }
}
