@font-face {
  font-family: "Outfit";
  src: url("/fonts/Outfit-Variable.ttf") format("truetype");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root,
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --sidebar: rgba(245, 245, 247, 0.86);
  --panel: #ffffff;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.12);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --faint: #8e8e93;
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --accent-soft: rgba(34, 197, 94, 0.12);
  --accent-text: #ffffff;
  --ok: #248a3d;
  --ok-soft: rgba(36, 138, 61, 0.12);
  --warn: #b25000;
  --warn-soft: rgba(178, 80, 0, 0.12);
  --danger: #d70015;
  --danger-soft: rgba(215, 0, 21, 0.1);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.06);
  --modal-scrim: rgba(0, 0, 0, 0.32);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Outfit", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --sidebar: rgba(28, 28, 30, 0.92);
  --panel: #1c1c1e;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f5f7;
  --muted: #a1a1a6;
  --faint: #8e8e93;
  --accent: #30d158;
  --accent-hover: #4ade80;
  --accent-soft: rgba(48, 209, 88, 0.18);
  --accent-text: #ffffff;
  --ok: #30d158;
  --ok-soft: rgba(48, 209, 88, 0.16);
  --warn: #ff9f0a;
  --warn-soft: rgba(255, 159, 10, 0.16);
  --danger: #ff453a;
  --danger-soft: rgba(255, 69, 58, 0.16);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-card: 0 2px 14px rgba(0, 0, 0, 0.35);
  --modal-scrim: rgba(0, 0, 0, 0.55);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

[hidden] {
  display: none !important;
}

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.15rem;
  padding-top: max(0.9rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: var(--sidebar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.brand-logo {
  width: 1.65rem;
  height: 1.65rem;
  flex-shrink: 0;
  color: var(--accent);
}

.brand-mark {
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.brand-mark em {
  font-style: normal;
  color: var(--accent);
  font-weight: 650;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--muted);
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

html[data-theme="light"] .theme-ico-sun,
html[data-theme="dark"] .theme-ico-moon {
  display: none;
}

.wrap {
  width: min(1120px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1.25rem 0 3rem;
  padding-bottom: max(3rem, env(safe-area-inset-bottom));
}

.auth-page {
  min-height: calc(100vh - 5rem);
  min-height: calc(100dvh - 5rem);
  display: grid;
  place-items: center;
  padding: 1.5rem 0;
}

.auth-shell {
  width: 100%;
  max-width: 420px;
}

.auth-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.2rem;
}

.auth-card {
  padding: 2rem 1.75rem 1.5rem;
  border-radius: calc(var(--radius) + 4px);
}

.auth-brand {
  text-align: center;
  margin-bottom: 1.15rem;
}

.auth-sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.auth-title {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-hint,
.page-sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.auth-hint {
  margin: 0 0 1.25rem;
}

.field {
  margin-bottom: 1rem;
}

.field label,
.row-form label,
.col-add label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.88rem;
  color: var(--muted);
}

input[type="text"] {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-error {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.55rem 0.95rem;
  border-radius: 980px;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 520;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.btn:hover {
  background: var(--bg);
}

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

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

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

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

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

.btn-ghost:hover {
  background: var(--accent-soft);
}

.btn-danger {
  background: var(--danger);
  border-color: transparent;
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(1.05);
  border-color: transparent;
}

.auth-submit {
  width: 100%;
  margin-top: 0.25rem;
  min-height: 2.75rem;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.15rem;
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-size: clamp(1.65rem, 2.6vw, 2rem);
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.loading-text {
  color: var(--muted);
  font-size: 1rem;
}

.create-form .btn,
.row-form .btn,
.col-add .btn {
  min-height: 2.75rem;
}

.row-form-line,
.col-add-line,
.link-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.row-form-line input,
.col-add-line input {
  flex: 1 1 12rem;
  min-width: 0;
}

.created-list {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.85rem;
}

.created-heading {
  margin: 0.15rem 0 0;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
}

.link-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1rem 1.05rem 1.05rem;
}

.link-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.link-row {
  margin-bottom: 0.75rem;
}

.link-row span,
.summary-label,
.col-label,
.row-name {
  overflow-wrap: anywhere;
}

.link-kicker {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.link-url {
  display: block;
  margin: 0.2rem 0 0.45rem;
  font-size: 0.86rem;
  line-height: 1.4;
  word-break: break-all;
  color: var(--text);
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.65rem;
  margin: 0.9rem 0;
}

.summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 0.8rem 0.9rem;
}

.summary-card.is-best {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.summary-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.counts {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.best-pill {
  display: inline-block;
  margin-top: 0.4rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ok);
  font-size: 0.75rem;
  font-weight: 650;
}

.column-admin {
  margin-bottom: 0.9rem;
}

.column-admin h2,
.stack-title {
  margin: 0 0 0.7rem;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.col-edit {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  padding: 0.65rem 0;
  border-top: 1px solid var(--line);
}

.col-edit input {
  flex: 1 1 10rem;
  min-width: 0;
}

.col-edit .btn {
  min-height: 2.6rem;
}

.empty {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.board-table-wrap {
  overflow: visible;
  max-height: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-card);
}

.board-table {
  width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.board-table th,
.board-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.board-table th {
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: -0.02em;
}

.board-table thead th {
  position: sticky;
  top: calc(max(0.9rem, env(safe-area-inset-top)) + 2.55rem + 1px);
  z-index: 2;
  background: var(--bg-elevated);
}

.board-table tfoot td {
  background: var(--bg-elevated);
  border-top: 1px solid var(--line-strong);
  border-bottom: 0;
}

.board-table th:first-child,
.board-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--bg-elevated);
  box-shadow: 1px 0 0 var(--line);
}

.board-table thead th:first-child,
.board-table tfoot td:first-child {
  z-index: 4;
}

.board-table .col-head,
.board-table .col-cell,
.board-table .col-count {
  width: calc(3 * 3rem + 2 * 0.35rem + 1.5rem);
  min-width: calc(3 * 3rem + 2 * 0.35rem + 1.5rem);
  max-width: calc(3 * 3rem + 2 * 0.35rem + 1.5rem);
}

.col-label,
.col-count .counts,
.row-name-text {
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
  -webkit-hyphens: auto;
  hyphenate-character: "-";
}

.board-table th.is-best,
.board-table td.is-best {
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-elevated));
}

.row-name {
  font-weight: 600;
}

.row-name-line {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.35rem;
  min-width: 0;
}

.row-name-text {
  flex: 1 1 4rem;
  min-width: 0;
  margin-bottom: 0.15rem;
}

.row-edit {
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
}

.row-edit svg {
  width: 1rem;
  height: 1rem;
}

.row-rename-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

.row-rename-form input,
.row-rename-form .btn,
.row-add-input,
.row-add-btn {
  width: 100%;
  max-width: 100%;
  min-height: 2.75rem;
  box-sizing: border-box;
}

.row-add-form {
  margin: 0;
}

.row-add-btn {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.2;
  padding: 0.45rem 0.35rem;
}

.row-delete {
  min-height: 2.75rem;
  padding: 0.35rem 0.8rem;
}

.mine-pill {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.08rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ok);
  font-size: 0.72rem;
  font-weight: 650;
  vertical-align: middle;
}

.choices {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  min-width: 0;
  max-width: 100%;
}

.choice {
  flex: 0 0 3rem;
  width: 3rem;
  height: 3rem;
  min-width: 3rem;
  min-height: 3rem;
  max-width: 3rem;
  max-height: 3rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.choice .mark,
.count-bit .mark {
  width: 1.35rem;
  height: 1.35rem;
  display: block;
  flex: 0 0 auto;
}

.count-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
}

.count-bit {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  font-weight: 650;
  line-height: 1;
}

.count-bit.is-ja { color: var(--ok); }
.count-bit.is-vielleicht { color: var(--warn); }
.count-bit.is-nein { color: var(--danger); }

.choice.is-ja { color: var(--ok); }
.choice.is-vielleicht { color: var(--warn); }
.choice.is-nein { color: var(--danger); }

.choice:disabled {
  cursor: default;
  opacity: 0.85;
}

.choice.is-selected.is-ja {
  background: var(--ok);
  border-color: transparent;
  color: #fff;
}

.choice.is-selected.is-vielleicht {
  background: var(--warn);
  border-color: transparent;
  color: #fff;
}

.choice.is-selected.is-nein {
  background: var(--danger);
  border-color: transparent;
  color: #fff;
}

html.has-code #screen-start {
  display: none !important;
}

html.has-code #screen-loading {
  display: grid !important;
}

@media (max-width: 860px) {
  .wrap {
    width: min(100% - 1rem, 1120px);
  }

  .auth-card {
    padding: 1.5rem 1.1rem 1.2rem;
  }

  .btn,
  input[type="text"] {
    min-height: 3rem;
  }

  .choice {
    width: 3rem;
    height: 3rem;
    min-width: 3rem;
    min-height: 3rem;
    max-width: 3rem;
    max-height: 3rem;
  }

  .theme-toggle {
    min-height: 2.75rem;
  }
}
