/* Muko Literatur – Gestaltung angelehnt an musikverein-langnau.clubdesk.com:
   Orange wie die Krawatten, Anthrazit wie die Anzüge, warmes Weiss,
   «Open Sans» schmal für Text und «Permanent Marker» für Titel. */

:root {
  --bg: #fbf7f1;
  --surface: #ffffff;
  --surface-2: #f6f0e7;
  --text: #45494e;               /* Anthrazit statt Schwarz */
  --muted: #7b7d80;
  --border: #ebe2d5;
  --ink: #52575d;                 /* Anthrazit für Kopfzeilen und Titel */
  --accent: #f8981c;              /* MVL-Orange */
  --accent-ink: #b05d00;          /* Orange als Schrift auf Weiss (lesbar) */
  --on-accent: #3d342a;
  --accent-soft: #fdecd5;
  --good: #2e7a4c;
  --good-soft: #e2f1e7;
  --warn: #946400;
  --warn-soft: #fbf0d6;
  --bad: #ac3f2b;
  --bad-soft: #f9e3dd;
  --info-soft: #ebe8f4;
  --shadow: 0 1px 2px rgb(60 40 10 / 6%), 0 6px 20px rgb(60 40 10 / 6%);
  --radius: 14px;
  --radius-sm: 9px;
  --font: "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-title: "Permanent Marker", "Open Sans", cursive;
  --narrow: 87.5%;
  --condensed: 75%;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412;
    --surface: #201d1a;
    --surface-2: #2a2622;
    --text: #efe9e2;
    --muted: #a89f95;
    --border: #39332d;
    --ink: #3a3631;
    --accent: #f8a43a;
    --accent-ink: #f8a43a;
    --on-accent: #2e2418;
    --accent-soft: #3a2a17;
    --good: #7ccb96;
    --good-soft: #1f3327;
    --warn: #e6b85c;
    --warn-soft: #3a2f19;
    --bad: #ef8f7b;
    --bad-soft: #3e241f;
    --info-soft: #2a2838;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 16px/1.5 var(--font);
  font-stretch: var(--narrow);
  -webkit-text-size-adjust: 100%;
  background:
    radial-gradient(1200px 600px at 100% -10%, rgb(248 152 28 / 14%), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgb(248 152 28 / 9%), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

a { color: var(--accent-ink); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-family: var(--font-title); font-weight: 400; font-size: 1.55rem; letter-spacing: .01em; color: var(--ink); }
h3 { font-size: 1.1rem; font-stretch: var(--condensed); font-weight: 700; }
@media (prefers-color-scheme: dark) { h2 { color: var(--text); } }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.loading { padding: 3rem; text-align: center; color: var(--muted); }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgb(255 255 255 / 88%);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 3px solid var(--accent);
}
@media (prefers-color-scheme: dark) { .topbar { background: rgb(32 29 26 / 90%); } }
.topbar-inner, nav.tabs { max-width: 1140px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.topbar-inner { padding-top: .55rem; padding-bottom: .2rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; }
.brand { display: flex; align-items: center; gap: .65rem; margin-right: auto; text-decoration: none; color: var(--ink); }
.brand img { height: 42px; width: auto; display: block; }
.brand .brand-text { font-family: var(--font-title); font-size: 1.45rem; line-height: 1; color: var(--ink); }
.brand .brand-text em { font-style: normal; color: var(--accent); }
@media (prefers-color-scheme: dark) {
  .brand img { background: #fff; border-radius: 8px; padding: 3px 5px; }
  .brand .brand-text { color: var(--text); }
}
.topbar select { max-width: 11rem; font-weight: 600; }
.person-btn { font-weight: 600; }
nav.tabs { display: flex; gap: .15rem; overflow-x: auto; scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a {
  padding: .5rem .8rem .55rem; text-decoration: none; color: var(--text);
  font-stretch: var(--condensed); font-size: 1.12rem; font-weight: 400; white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -3px; transition: color .15s;
}
nav.tabs a:hover { color: var(--accent-ink); }
nav.tabs a.active { color: var(--accent-ink); border-bottom-color: var(--accent-ink); font-weight: 600; }
main { max-width: 1140px; margin: 0 auto; padding: 1.5rem 16px 4rem; }

/* ---------- Bausteine ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.15rem 1.25rem; box-shadow: var(--shadow);
}
.stack > * + * { margin-top: .9rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.spread { justify-content: space-between; }
.grow { flex: 1 1 auto; }

button, .btn {
  font: inherit; font-stretch: var(--narrow); cursor: pointer; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .5rem .9rem; min-height: 40px; text-decoration: none;
  display: inline-flex; align-items: center; gap: .4rem;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
button:hover, .btn:hover { border-color: var(--accent); color: var(--accent-ink); }
button.primary {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700;
  box-shadow: 0 2px 8px rgb(248 152 28 / 30%);
}
button.primary:hover { background: #ffa733; color: var(--on-accent); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
button.ghost:hover { color: var(--accent-ink); }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); color: var(--bad); }
button:disabled { opacity: .4; cursor: default; pointer-events: none; }
button.icon { padding: .35rem .6rem; min-height: 34px; }

input, select, textarea {
  font: inherit; font-stretch: var(--narrow); color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem .7rem; min-height: 40px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { width: 100%; min-height: 4.5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgb(248 152 28 / 22%); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label.field { display: grid; gap: .3rem; font-size: .85rem; color: var(--muted); font-weight: 600; }
label.field > input, label.field > select, label.field > textarea { color: var(--text); font-size: 1rem; font-weight: 400; }
.form-grid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }

.badge {
  display: inline-block; font-size: .78rem; padding: .12rem .55rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap; font-weight: 600;
}
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent-ink); }

.avg {
  font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2.7rem; text-align: center;
  border-radius: var(--radius-sm); padding: .25rem .45rem; background: var(--surface-2);
}
.avg.hi { background: var(--good-soft); color: var(--good); }
.avg.mid { background: var(--warn-soft); color: var(--warn); }
.avg.lo { background: var(--bad-soft); color: var(--bad); }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }

/* ---------- Anmeldung ---------- */
.center-box { max-width: 400px; margin: 10vh auto 2rem; padding: 0 16px; }
.center-box .card { padding: 1.75rem; border-top: 4px solid var(--accent); }
.login-logo { display: block; height: 72px; width: auto; margin: 0 auto .75rem; }
@media (prefers-color-scheme: dark) { .login-logo { background: #fff; border-radius: 10px; padding: 6px 10px; } }
.center-box h2 { text-align: center; font-size: 1.9rem; }
.center-box p { text-align: center; }
.person-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .55rem; }
.person-grid button { justify-content: center; min-height: 54px; font-weight: 700; font-size: 1.05rem; }

/* ---------- Hörmodus ---------- */
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, #f7b04f, var(--accent)); border-radius: 99px; transition: width .4s; }
.rate-card { border-top: 4px solid var(--accent); }
.piece-head h2 { font-family: var(--font); font-stretch: var(--condensed); font-weight: 700; font-size: 1.75rem; margin-bottom: .1rem; }
.player {
  position: relative; aspect-ratio: 16 / 9; max-width: 760px; background: var(--ink);
  border-radius: var(--radius); overflow: hidden; box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
}
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.section-label { font-weight: 700; font-stretch: var(--condensed); font-size: 1.05rem; }
.notes { display: grid; grid-template-columns: repeat(11, 1fr); gap: .3rem; }
.notes button { justify-content: center; padding: .4rem 0; font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; min-height: 48px; }
.notes button.half { font-weight: 400; font-size: .85rem; color: var(--muted); }
.notes button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 2px 8px rgb(248 152 28 / 35%); }
.fits { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.fits button { justify-content: center; min-height: 48px; }
.fits button.on[data-fit="ja"] { background: var(--good-soft); border-color: var(--good); color: var(--good); font-weight: 700; }
.fits button.on[data-fit="spaeter"] { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); font-weight: 700; }
.fits button.on[data-fit="anders"] { background: var(--info-soft); border-color: var(--muted); color: var(--text); font-weight: 700; }
.queue { display: flex; flex-wrap: wrap; gap: .35rem; }
.queue button { min-height: 32px; padding: .2rem .65rem; font-size: .85rem; border-radius: 999px; }
.queue button.done { background: var(--good-soft); color: var(--good); border-color: transparent; }
.queue button.current { border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
details.others { border-top: 1px dashed var(--border); padding-top: .75rem; }
details.others summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.opinions { display: grid; gap: .55rem; margin-top: .6rem; }
.opinion { display: grid; grid-template-columns: 5.5rem 2.7rem 1fr; gap: .6rem; align-items: start; font-size: .93rem; }
.opinion .who { font-weight: 700; }

.half-toggle { display: none; }

@media (max-width: 560px) {
  .notes { grid-template-columns: repeat(6, 1fr); }
  .notes button.half { display: none; }
  .notes button.part { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
  .notes button.part::after { content: "½"; }
  .half-toggle { display: inline-flex; align-self: flex-start; }
  .opinion { grid-template-columns: 4.5rem 2.7rem 1fr; }
  .piece-head h2 { font-size: 1.45rem; }
  .card { padding: 1rem; }
}

/* ---------- Sitzung ---------- */
.buckets { display: grid; gap: 1.25rem; }
.bucket > h3 {
  display: flex; align-items: center; gap: .5rem; margin: 0;
  padding: .7rem 1rem; background: var(--accent); color: var(--on-accent); font-size: 1.2rem;
}
.bucket > h3 .badge { background: rgb(255 255 255 / 55%); color: var(--on-accent); }
.bucket > .bucket-hint { margin: 0; padding: .55rem 1rem; background: var(--accent-soft); color: var(--text); font-size: .875rem; }
.piece-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: center;
  padding: .7rem 1rem; border-top: 1px solid var(--border); transition: background .15s;
}
.piece-row:hover { background: var(--surface-2); }
.piece-title { font-weight: 700; }
.piece-meta { font-size: .85rem; color: var(--muted); }
.list-card { padding: 0; overflow: hidden; }
.list-card > .piece-row:first-child, .list-card > div:first-child > .piece-row { border-top: 0; }
.expand { padding: .25rem 1rem 1rem; background: var(--surface-2); border-top: 1px dashed var(--border); }

/* ---------- Programm ---------- */
.prog-row {
  display: grid; grid-template-columns: 2.2rem 1fr auto auto; gap: .7rem; align-items: center;
  padding: .65rem 1rem; border-top: 1px solid var(--border); background: var(--surface);
}
.prog-row:first-child { border-top: 0; }
.prog-row.dragging { opacity: .5; }
.prog-row.over { box-shadow: inset 0 3px 0 var(--accent); }
.prog-pos {
  font-family: var(--font-title); font-size: 1.2rem; color: var(--accent-ink); text-align: center; cursor: grab;
}
.total { font-size: 1.9rem; font-weight: 700; font-stretch: var(--condensed); font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; }
.stats .card { padding: .85rem 1.1rem; border-left: 4px solid var(--accent); }

/* ---------- Pool ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.toolbar input[type=search] { flex: 1 1 200px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg button { border: 0; border-radius: 0; min-height: 38px; box-shadow: none; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--ink); color: #fff; font-weight: 700; }
.seg button.on .muted { color: rgb(255 255 255 / 70%); }
@media (prefers-color-scheme: dark) { .seg button.on { background: var(--accent); color: var(--on-accent); } .seg button.on .muted { color: var(--on-accent); } }
.star { font-size: 1.1rem; }
.star.on { color: var(--accent-ink); border-color: var(--accent); background: var(--accent-soft); }
.warnbox { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius-sm); padding: .6rem .85rem; font-size: .9rem; border-left: 4px solid var(--warn); }

/* ---------- Tabelle (Excel-Ansicht) ---------- */
main.wide { max-width: none; }
.table-wrap {
  overflow: auto; max-height: calc(100vh - 235px); min-height: 300px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow); -webkit-overflow-scrolling: touch;
}
table.grid { border-collapse: separate; border-spacing: 0; font-size: .88rem; min-width: 100%; }
table.grid th, table.grid td {
  padding: .4rem .6rem; text-align: left; vertical-align: top; background: var(--surface);
  border-bottom: 1px solid var(--border); border-right: 1px solid var(--border);
}
table.grid thead th {
  position: sticky; top: 0; z-index: 2; background: var(--ink); color: #fff;
  font-stretch: var(--condensed); font-size: .95rem; font-weight: 600; white-space: nowrap;
  cursor: pointer; user-select: none; border-right-color: rgb(255 255 255 / 12%); border-bottom: 3px solid var(--accent);
}
table.grid thead th:hover { color: var(--accent); }
table.grid .fixed { position: sticky; left: 0; z-index: 1; min-width: 11rem; max-width: 16rem; box-shadow: 3px 0 0 var(--border); }
table.grid thead th.fixed { z-index: 3; box-shadow: 3px 0 0 rgb(255 255 255 / 12%); }
table.grid td.clip, table.grid td.person { max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.grid td.person { min-width: 9rem; }
table.grid.wrap td.clip, table.grid.wrap td.person { white-space: normal; min-width: 14rem; }
table.grid td.num, table.grid td.nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.grid tbody tr:nth-child(even) td { background: #fdfbf8; }
@media (prefers-color-scheme: dark) { table.grid tbody tr:nth-child(even) td { background: #23201c; } }
table.grid tbody tr:hover td { background: var(--accent-soft); }
table.grid th.mine { background: var(--accent); color: var(--on-accent); }
table.grid td.mine { cursor: pointer; box-shadow: inset 3px 0 0 var(--accent); }
table.grid td.mine:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
table.grid td:has(.cell-editor) { white-space: normal; max-width: none; outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface) !important; }
.avg.sm { font-size: .8rem; min-width: 2rem; padding: .05rem .3rem; display: inline-block; }
.linklike {
  background: none; border: 0; padding: 0; min-height: 0; font: inherit; font-weight: 700;
  color: var(--text); text-align: left; cursor: pointer; box-shadow: none;
}
.linklike:hover { color: var(--accent-ink); text-decoration: underline; }
.style-chip {
  display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap;
  background: hsl(var(--h) 60% 92%); color: hsl(var(--h) 45% 28%);
}
@media (prefers-color-scheme: dark) {
  .style-chip { background: hsl(var(--h) 28% 22%); color: hsl(var(--h) 60% 80%); }
}
.cell-editor { display: grid; gap: .35rem; min-width: 15rem; cursor: default; }
.cell-editor select, .cell-editor textarea, .cell-editor button { min-height: 32px; font-size: .86rem; padding: .25rem .45rem; }
.cell-editor textarea { min-height: 3.2rem; }
.colpick { position: relative; }
.colpick summary { list-style: none; }
.colpick summary::-webkit-details-marker { display: none; }
.colpick-menu {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; padding: .75rem .9rem;
  display: grid; gap: .3rem; min-width: 14rem; max-height: 60vh; overflow: auto;
}
@media (max-width: 560px) {
  .table-wrap { max-height: calc(100vh - 290px); }
  table.grid .fixed { min-width: 8rem; max-width: 9.5rem; }
}

/* ---------- Dialog ---------- */
dialog {
  border: 0; border-radius: var(--radius); padding: 0; border-top: 4px solid var(--accent);
  width: min(780px, calc(100vw - 24px)); max-height: calc(100vh - 24px);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / 30%);
}
dialog::backdrop { background: rgb(30 22 12 / 45%); backdrop-filter: blur(2px); }
dialog .dlg-body { padding: 1.25rem 1.35rem; overflow: auto; max-height: calc(100vh - 115px); }
dialog .dlg-foot { padding: .85rem 1.35rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; background: var(--surface-2); }

#toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%) translateY(160%);
  background: var(--ink); color: #fff; padding: .65rem 1.1rem; border-radius: 999px;
  border-left: 4px solid var(--accent); box-shadow: 0 8px 24px rgb(0 0 0 / 25%);
  transition: transform .25s; z-index: 50; max-width: calc(100vw - 32px);
}
#toast.show { transform: translateX(-50%) translateY(0); }

table.simple { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.simple th, table.simple td { text-align: left; padding: .5rem .55rem; border-top: 1px solid var(--border); vertical-align: middle; }
table.simple th { color: var(--muted); font-weight: 600; border-top: 0; font-stretch: var(--condensed); }

.print-only { display: none; }
@media print {
  .topbar, .no-print, #toast { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; color: #000; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .prog-row { grid-template-columns: 2.2rem 1fr auto; }
  .prog-row .no-print { display: none; }
}
