:root {
  --paper: #f5eedf;
  --surface: #fbf7ee;
  --ink: #33261c;
  --ink-muted: #7a6a57;
  --line: #e6d9c2;
  --accent: #b5533c;
  --accent-ink: #fff8f0;
  --status-open: #c98a2c;
  --status-open-bg: #f3e2c2;
  --status-done: #6b7f5e;
  --status-done-bg: #e2e8dc;
}

* {
  box-sizing: border-box;
}

/* An element's own `display` rule (e.g. .icon-button's inline-flex) has the
   same specificity as the UA stylesheet's `[hidden]{display:none}` and,
   being an author rule, wins — so hidden buttons stayed visible. */
[hidden] {
  display: none !important;
}

body {
  font-family: "Karla", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  margin: 0;
  padding: 1.5rem 1rem 3rem;
}

main {
  max-width: 820px;
  margin: 0 auto;
}

.page-header {
  max-width: 820px;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.add-button {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: none;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.intro {
  color: var(--ink-muted);
  max-width: 40ch;
}

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

.button {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  border-radius: 0.4rem;
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

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

.button-quiet {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

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

.logout-link {
  display: inline-block;
  margin-top: 1.25rem;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.greeting {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  color: var(--ink-muted);
}

.error {
  background: var(--status-open-bg);
  color: #6b3f13;
  border: 1px solid var(--status-open);
  border-radius: 0.4rem;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
}

.list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.list-header,
.row {
  /* The actions column is a fixed width, not auto: auto-sizing is computed
     independently per grid box, and the header's empty actions cell would
     collapse to ~0 while a row's icon buttons need ~8rem, silently pulling
     every column out of alignment between the header and the rows. */
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) 5.5rem 8rem;
  grid-template-areas: "anliegen status actions";
  gap: 0.25rem 0.75rem;
  align-items: center;
  padding: 0.85rem 1rem;
}

.list-header {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--line);
}

.row {
  border-bottom: 1px solid var(--line);
}

.row:last-child {
  border-bottom: none;
}

.cell-anliegen { grid-area: anliegen; min-width: 0; }
.cell-status { grid-area: status; }
.cell-actions {
  grid-area: actions;
  display: flex;
  justify-content: flex-end;
}

.cell-anliegen {
  overflow-wrap: break-word;
}

.anliegen-text {
  line-height: 1.35;
}

.cell-meta {
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-top: 0.2rem;
}

.button-group {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  overflow: hidden;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--ink-muted);
}

.button-group .icon-button:last-child {
  border-right: none;
}

.icon-button:hover {
  background: var(--paper);
  color: var(--ink);
}

.icon-button-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.icon-button-primary:hover {
  background: var(--accent);
  color: var(--accent-ink);
  filter: brightness(1.08);
}

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}

.status-pill.status-offen {
  background: var(--status-open-bg);
  color: #7a4f18;
}

.status-pill.status-erledigt {
  background: var(--status-done-bg);
  color: #445138;
}

.row.status-erledigt .anliegen-text {
  color: var(--ink-muted);
  text-decoration: line-through;
}

button {
  cursor: pointer;
}

.anliegen-dialog {
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  width: min(30rem, calc(100vw - 2rem));
}

.anliegen-dialog::backdrop {
  background: rgba(51, 38, 28, 0.45);
}

.anliegen-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.25rem;
}

.anliegen-form h2 {
  margin: 0;
  font-size: 1.15rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.field input,
.field textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: #fff;
  color: var(--ink);
}

.field textarea {
  resize: vertical;
  min-height: 6rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

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

@media (max-width: 640px) {
  .list {
    background: transparent;
    border: none;
    overflow: visible;
  }

  .list-header {
    display: none;
  }

  .row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "anliegen anliegen"
      "status actions";
    gap: 0.5rem 0.75rem;
    padding: 0.9rem 1rem;
    background: var(--surface);
    border-bottom: none;
    border-left: 4px solid var(--line);
    border-radius: 0 0.4rem 0.4rem 0;
    margin-bottom: 0.6rem;
  }

  .row:last-child {
    margin-bottom: 0;
  }

  .row.status-offen {
    border-left-color: var(--status-open);
  }

  .row.status-erledigt {
    border-left-color: var(--status-done);
  }

  .anliegen-text {
    font-weight: 500;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
