:root {
  color-scheme: light only;
  /* Primary */
  --primary: #e67e22;

  /* Tints */
  --tint-1: #fdf2e9;
  --tint-2: #fae5d3;
  --tint-3: #eb984e;

  /* Shades */
  --shade-1: #cf711f;
  --shade-2: #45260a;

  /* Greys */
  --grey-1: #888;
  --grey-2: #767676;
  --grey-3: #6f6f6f;
  --grey-4: #555;
  --grey-5: #333;

  /* Funktionale Farben */
  --bg-primary: #fdf2e9;
  --bg-secondary: #fff;
  --text-primary: #333;
  --text-secondary: #555;
  --text-muted: #767676;
  --border: #e8d5c4;
  --focus: #cf711f;
  --warn: #d90606;
  --success: #059669;

  --input-h: 48px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  padding: 20px;
  line-height: 1.6;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  gap: 20px;
  margin-bottom: 0.5rem;
}

header {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  justify-content: left;
}

header h1 {
  font-size: clamp(20px, 3vw, 28px);
  margin: 0 0 8px 0;
  color: var(--shade-2);
  letter-spacing: -0.5px;
}

.subtext {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  margin: 8px 0 0 0;
}

.controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 16px;
}

button {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1.5px solid var(--primary);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  white-space: nowrap;
}

button:hover {
  background: var(--tint-1);
  border-color: var(--shade-1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(230, 126, 34, 0.15);
}

button:active {
  transform: translateY(0);
}

button.primary {
  background: var(--primary);
  color: var(--bg-secondary);
  border-color: var(--primary);
}

button.primary:hover {
  background: var(--shade-1);
  border-color: var(--shade-1);
  box-shadow: 0 4px 12px rgba(207, 113, 31, 0.2);
}

button.primary[data-state="shown"] {
  background: var(--success);
  border-color: var(--success);
}

button.primary[data-state="shown"]:hover {
  background: #047857;
  border-color: #047857;
}

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1150px;
  font-size: 14px;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--tint-1);
  z-index: 10;
  text-align: left;
  padding: 14px 12px;
  border-bottom: 2px solid var(--primary);
  font-weight: 600;
  color: var(--shade-2);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  background: var(--bg-secondary);
  transition: background 0.15s ease;
  white-space: pre-line;
  position: relative;
}

tbody tr:nth-child(even) td {
  background: #fafaf8;
}

tbody tr:hover td {
  background: inherit;
}

.cell-wrap {
  display: grid;
  gap: 8px;
  min-height: 68px;
}

.solution {
  color: var(--text-primary);
  line-height: 1.4;
  white-space: pre-line;
  font-size: 13px;
}

.solution.hidden-solution {
  color: transparent;
  user-select: none;
  min-height: 18px;
}

.user-input {
  width: 100%;
  height: var(--input-h);
  min-height: var(--input-h);
  max-height: 140px;
  resize: vertical;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  font-family: inherit;
  line-height: 1.4;
  transition: all 0.2s ease;
}

.user-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(230, 126, 34, 0.1);
}

.user-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #fafaf8;
}

/* Leere Inputs gelb im Lösungsmodus */
body.solutions-shown .user-input.empty-input {
  border-color: var(--warn);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.1);
  background: #fffbeb;
}

body.solutions-shown .user-input {
  color: var(--text-primary);
  border-color: var(--primary);
  background: var(--tint-1);
}

body.solutions-shown .solution {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--shade-2);
  font-weight: 500;
}

.row-btn {
  width: 100%;
  font-size: 13px;
  padding: 10px 12px;
}

.row-btn:hover {
  background: var(--tint-2);
}

/* Mobile: Tabelle -> Karten */
@media (max-width: 800px) {
  body {
    padding: 16px;
  }

  .card {
    padding: 12px;
    overflow: visible;
  }

  table {
    min-width: 0;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tbody tr {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 16px;
    overflow: hidden;
  }

  tbody td {
    border-bottom: 1px solid var(--border);
    background: transparent;
    padding: 12px;
  }

  tbody tr:nth-child(even) td {
    background: transparent;
  }

  tbody tr:hover td {
    background: inherit;
  }

  tbody td::before {
    content: attr(data-label);
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .row-btn {
    font-size: 14px;
    padding: 10px 12px;
  }

  :root {
    --input-h: 52px;
  }

  .cell-wrap {
    min-height: auto;
    gap: 6px;
  }
}

/* Loading State */
.loading {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 20px;
}

.loading::after {
  content: ".";
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%,
  20% {
    content: ".";
  }
  40% {
    content: "..";
  }
  60% {
    content: "...";
  }
  80%,
  100% {
    content: "";
  }
}

/* Error State */
.error {
  background: #fee2e2;
  border: 1.5px solid #dc2626;
  color: #991b1b;
  padding: 16px;
  border-radius: 8px;
  margin: 20px 0;
  text-align: center;
}

.logo {
  height: 32px;
  width: auto;
  vertical-align: middle;
  margin-right: 16px;
  display: inline-block;
}

.logo:hover {
  opacity: 0.75;
}

/* Mobile */
@media (max-width: 800px) {
  .logo {
    height: 28px;
    margin-right: 12px;
  }
}
