:root {
  color-scheme: light;
  --ink: #162132;
  --muted: #607086;
  --paper: #f3f6fa;
  --surface: #ffffff;
  --line: #dbe3ed;
  --blue: #1359ce;
  --blue-dark: #0b3f9c;
  --aqua: #119f91;
  --red: #bb3345;
  --red-soft: #fff0f2;
  --green: #137a54;
  --green-soft: #e8f7f0;
  --shadow: 0 18px 50px rgba(25, 46, 78, 0.09);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 16px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
.eyebrow { color: var(--blue); font-size: .78rem; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .65rem; font-size: clamp(2rem, 5vw, 3.7rem); letter-spacing: -.045em; line-height: 1; }
h2 { margin-bottom: .75rem; font-size: 1.3rem; letter-spacing: -.02em; }
p { color: var(--muted); line-height: 1.55; }
label { display: grid; gap: 8px; color: #334157; font-size: .9rem; font-weight: 750; }
input, select { width: 100%; min-height: 48px; padding: 0 14px; color: var(--ink); background: #fff; border: 1px solid #c9d3e1; border-radius: 10px; outline: none; }
input:focus, select:focus, button:focus-visible { border-color: var(--blue); outline: 3px solid rgba(19,89,206,.17); outline-offset: 1px; }
button { min-height: 44px; padding: 0 17px; border: 0; border-radius: 10px; font-weight: 800; }
.primary { color: #fff; background: var(--blue); }
.primary:hover { background: var(--blue-dark); }
.secondary { color: #24405e; background: #edf2f8; border: 1px solid #d7e0ea; }
.secondary:hover { background: #e2e9f2; }
.wide { width: 100%; }
.text-button { min-height: 36px; padding: 0 4px; color: var(--blue); background: transparent; }
.icon-button { width: 44px; padding: 0; color: #58697e; background: #e5ebf3; }
.form-message { margin: 12px 0 0; color: var(--muted); font-weight: 700; }
.form-message.error { color: var(--red); }
.form-message.success { color: var(--green); }

/* Schüleransicht */
.student-shell { width: min(780px, calc(100% - 32px)); margin: 0 auto; padding: clamp(42px, 8vw, 90px) 0; }
.intro-card { padding: clamp(24px, 5vw, 44px); color: #fff; background: radial-gradient(circle at 90% 0%, rgba(37,185,169,.75), transparent 35%), linear-gradient(135deg, #0d377d, #1359ce); border-radius: 28px 28px 10px 10px; box-shadow: var(--shadow); }
.intro-card .eyebrow, .intro-card p { color: #dfeaff; }
.intro-card p { margin: 0; max-width: 550px; font-size: 1.08rem; }
.access-card, .survey-card, .success-card { margin-top: 10px; padding: clamp(24px, 5vw, 40px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px 10px 28px 28px; box-shadow: var(--shadow); }
.access-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.access-grid button { align-self: end; }
.survey-head, .success-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.survey-head h2 { margin: 3px 0 0; font-size: 1.9rem; }
fieldset { margin: 24px 0 0; padding: 24px; border: 1px solid var(--line); border-radius: 16px; }
legend { padding: 0 8px; font-size: 1.1rem; font-weight: 850; }
fieldset p { margin: 0 0 16px; font-size: .92rem; }
.avoid-field { border-color: #f0ccd2; background: #fffafb; }
.number-picker { display: grid; grid-template-columns: repeat(9, 1fr); gap: 8px; }
.number-option { min-width: 0; min-height: 46px; padding: 0; color: #32475f; background: #eef3f8; border: 1px solid #d9e1eb; }
.number-option:hover { border-color: #9bb2ce; }
.number-option[aria-pressed="true"] { color: #fff; background: var(--blue); border-color: var(--blue); box-shadow: 0 4px 12px rgba(19,89,206,.22); }
.avoid-field .number-option[aria-pressed="true"] { background: var(--red); border-color: var(--red); box-shadow: 0 4px 12px rgba(187,51,69,.2); }
.survey-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 24px; }
.survey-actions .form-message { margin: 0; }
.success-card { border-radius: 10px 10px 28px 28px; }
.success-card h2 { margin-bottom: 4px; }
.success-card p { margin-bottom: 0; }
.success-mark { flex: 0 0 auto; display: grid; width: 54px; height: 54px; place-items: center; color: #fff; background: var(--green); border-radius: 50%; font-size: 1.65rem; font-weight: 900; }
.privacy-note { margin: 18px 12px; color: var(--muted); line-height: 1.5; }

/* Anmeldung */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, rgba(19,89,206,.12), transparent 36%), var(--paper); }
.login-card { width: min(440px, 100%); padding: 38px; background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.login-card h1 { margin-top: 8px; font-size: 2.35rem; }
.login-card form { display: grid; gap: 16px; margin-top: 26px; }

/* Admin */
.admin-body { padding: 24px; }
.admin-header { width: min(1480px, 100%); margin: 0 auto 18px; display: grid; grid-template-columns: minmax(190px, 1fr) auto minmax(280px, 1fr); align-items: end; gap: 20px; }
.admin-header h1 { margin: 4px 0 0; font-size: 2.2rem; }
.admin-tabs { display: flex; gap: 4px; padding: 4px; background: #e5ebf3; border-radius: 12px; }
.tab-button { min-height: 38px; padding: 0 16px; color: #5a6a7e; background: transparent; border-radius: 9px; }
.tab-button.active { color: var(--ink); background: #fff; box-shadow: 0 2px 8px rgba(34,55,82,.1); }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.status-pill { padding: 9px 13px; color: #38506e; background: #e6edf6; border-radius: 999px; font-size: .9rem; font-weight: 750; white-space: nowrap; }
.admin-grid { width: min(1480px, 100%); margin: auto; display: grid; grid-template-columns: minmax(270px, 330px) 1fr; gap: 18px; }
.admin-panel, .room-panel, .content-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.admin-panel { padding: 24px; }
.room-panel { min-width: 0; padding: clamp(20px, 3vw, 34px); }
.panel-heading, .content-heading, .room-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-heading h2, .room-top h2, .content-heading h2 { margin: 3px 0 0; }
.room-top h2 { font-size: 1.7rem; }
.count-badge { display: grid; width: 34px; height: 34px; place-items: center; color: var(--blue); background: #e8f0fd; border-radius: 50%; font-weight: 850; }
.constraint-form { display: grid; gap: 13px; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.constraint-list { display: grid; gap: 8px; margin-top: 18px; }
.constraint-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 10px 10px 13px; color: #3c4d61; background: #f3f6fa; border-radius: 10px; font-size: .86rem; font-weight: 700; }
.remove-button { flex: 0 0 auto; width: 30px; min-height: 30px; padding: 0; color: #758396; background: transparent; font-size: 1.25rem; }
.remove-button:hover { color: var(--red); background: #fff; }
.empty-state { padding: 28px 12px; color: #8390a1; border: 1px dashed #cbd5e2; border-radius: 12px; text-align: center; }
.room-actions { display: flex; gap: 8px; }
.alternative-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0; }
.alternative-button { display: grid; gap: 3px; height: auto; min-height: 58px; padding: 10px 12px; color: #53657a; background: #f0f4f8; border: 1px solid transparent; text-align: left; }
.alternative-button strong { color: var(--ink); }
.alternative-button span { font-size: .76rem; font-weight: 650; }
.alternative-button.active { background: #e9f1ff; border-color: var(--blue); }
.board { width: min(520px, 72%); margin: 10px auto 30px; padding: 9px; color: #d5e6e3; background: #244c47; border-bottom: 5px solid #bdc7c6; border-radius: 4px; text-align: center; font-size: .78rem; letter-spacing: .18em; text-transform: uppercase; }
.room { display: grid; gap: clamp(20px, 4vh, 36px); }
.room-row { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(30px, 7vw, 100px); }
.table { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 10px; background: #c7d0db; border: 1px solid #aeb9c8; border-radius: 8px; box-shadow: 0 5px 0 #95a2b2; }
.seat { display: grid; aspect-ratio: 1.18; min-height: 58px; padding: 4px; place-items: center; color: #164b92; background: #f7faff; border: 2px solid transparent; border-radius: 8px; font-style: normal; font-weight: 850; }
.seat:hover { background: #eaf2fc; }
.seat.selected { border-color: var(--aqua); outline: 3px solid rgba(17,159,145,.17); }
.seat.fixed { background: #e7f7f2; }
.seat.dragging { opacity: .45; }
.seat-number { font-size: clamp(1.05rem, 2vw, 1.45rem); }
.seat small { color: var(--green); font-size: .62rem; line-height: 1; text-transform: uppercase; }
.empty-seat { color: #96a3b3; font-size: .75rem; font-weight: 700; }
.plan-metrics { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.plan-metrics span { padding: 8px 11px; color: #486078; background: #edf3f7; border-radius: 999px; font-size: .82rem; }
.plan-metrics strong { color: var(--ink); }
.plan-metrics .metric-warning { color: #8f2432; background: var(--red-soft); }
.move-hint { margin: 16px 0 0; font-size: .83rem; }

/* Tabellen und Einstellungen */
.content-view { width: min(1480px, 100%); margin: 0 auto; }
.content-card { padding: clamp(22px, 3vw, 34px); }
.content-heading { margin-bottom: 24px; }
.content-heading p { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
thead th { color: #708095; background: #f5f7fa; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; }
tbody th { color: var(--blue); font-size: 1rem; }
.answer-status { display: inline-flex; padding: 5px 8px; border-radius: 999px; font-size: .76rem; font-weight: 800; }
.answer-status.done { color: var(--green); background: var(--green-soft); }
.answer-status.open { color: #68788b; background: #edf1f5; }
.settings-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; margin-bottom: 18px; }
.settings-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 22px; }
.settings-form button, .settings-form .form-message { align-self: end; }
.danger-card { border-color: #efccd2; }
.danger-card .eyebrow { color: var(--red); }
.danger-button { color: #fff; background: var(--red); }
.danger-quiet { color: var(--red); background: var(--red-soft); border: 1px solid #f0cbd1; }
.codes-card { margin-bottom: 40px; }
.code-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; margin-top: 24px; }
.code-card { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; padding: 13px; background: #f2f6fa; border: 1px dashed #bdc9d7; border-radius: 10px; }
.code-card span { color: #78879a; font-size: .68rem; text-transform: uppercase; }
.code-card strong { justify-self: end; color: var(--blue); }
.code-card code { grid-column: 1 / -1; font-size: 1.13rem; font-weight: 850; letter-spacing: .08em; }
.code-card small { grid-column: 1 / -1; color: #77869a; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1050px) {
  .admin-header { grid-template-columns: 1fr auto; align-items: center; }
  .admin-tabs { grid-row: 2; grid-column: 1 / -1; justify-self: start; }
  .code-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 780px) {
  .access-grid, .admin-grid, .settings-grid { grid-template-columns: 1fr; }
  .admin-header { display: flex; align-items: flex-start; flex-direction: column; }
  .admin-tabs { order: 3; width: 100%; overflow-x: auto; }
  .tab-button { flex: 1; }
  .header-actions { width: 100%; justify-content: space-between; }
  .admin-body { padding: 14px; }
  .room-row { gap: 18px; }
  .table { gap: 4px; padding: 6px; }
  .seat { min-height: 44px; }
  .number-picker { grid-template-columns: repeat(7, 1fr); }
  .code-grid { grid-template-columns: repeat(3, 1fr); }
  .content-heading { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 520px) {
  .access-grid, .settings-form { grid-template-columns: 1fr; }
  .student-shell { width: min(100% - 20px, 780px); padding: 20px 0; }
  .survey-head, .survey-actions, .success-card { align-items: flex-start; flex-direction: column; }
  fieldset { padding: 18px 14px; }
  .number-picker { grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .room-panel { overflow-x: auto; }
  .room, .board, .alternative-bar, .plan-metrics, .room-top, .move-hint, #plan-message { min-width: 580px; }
  .code-grid { grid-template-columns: repeat(2, 1fr); }
  .room-actions { flex-wrap: wrap; }
}

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; }
  .admin-header, .constraints-panel, .room-actions, .alternative-bar, .plan-metrics, .move-hint, .form-message, .settings-grid, .codes-card > p { display: none !important; }
  .admin-body { padding: 0; }
  .admin-grid { display: block; width: 100%; }
  .room-panel, .content-card { padding: 0; border: 0; box-shadow: none; }
  .room { gap: 16px; }
  .room-row { gap: 55px; break-inside: avoid; }
  .seat { min-height: 50px; border: 1px solid #d4dce5; }
  .code-grid { grid-template-columns: repeat(7, 1fr); gap: 7px; }
  .code-card { break-inside: avoid; }
}
