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

:root {
  --primary:   #2563eb;
  --primary-h: #1d4ed8;
  --danger:    #dc2626;
  --success:   #16a34a;
  --warn:      #d97706;
  --bg:        #f1f5f9;
  --card:      #ffffff;
  --border:    #e2e8f0;
  --text:      #1e293b;
  --muted:     #64748b;
  --radius:    8px;

  /* Buehnenfarben - identisch zur Mac-App, damit Bildschirm und Ausdruck
     mit den anderen Choreo-Programmen uebereinstimmen. */
  --herr:      #000080;
  --dame:      #008000;
  --mitte:     #ff3b30;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* ── Nav ─────────────────────────────────────────────────────────────────── */
.nav {
  background: var(--primary);
  color: #fff;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 200;
}
.nav-brand { font-weight: 700; font-size: 1.05rem; text-decoration: none; color: #fff; white-space: nowrap; display: flex; align-items: center; gap: .5rem; }
.nav-links { display: flex; gap: .75rem; margin-left: auto; }
.nav-links a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: .9rem;
  padding: .25rem .6rem;
  border-radius: 4px;
}
.nav-links a:hover { background: rgba(255,255,255,.15); color: #fff; }
.nav-user { display: flex; align-items: center; gap: .6rem; font-size: .85rem; opacity: .9; white-space: nowrap; }
.nav-user a { color: rgba(255,255,255,.8); text-decoration: none; }
.nav-user a:hover { color: #fff; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.page-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.25rem; }
.page-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head .page-title { margin-bottom: 0; }
.page-head .spacer { margin-left: auto; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .45rem 1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-h); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: .85; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #cbd5e1; }
.btn-sm { padding: .3rem .7rem; font-size: .82rem; }
.btn-block { width: 100%; }

/* ── Formulare ───────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .35rem; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .9rem;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ── Anmeldung ───────────────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; }
.auth-logo { font-size: 1.4rem; font-weight: 800; color: var(--primary); text-align: center; }
.auth-sub  { color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; text-align: center; }
.auth-tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.auth-tab  { padding: .5rem 1rem; cursor: pointer; font-size: .9rem; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Meldungen ───────────────────────────────────────────────────────────── */
.alert { padding: .65rem 1rem; border-radius: 6px; font-size: .875rem; margin-bottom: 1rem; }
.alert-error   { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alert-info    { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ── Tabellen ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .65rem .9rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--bg); font-weight: 600; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-admin   { background: #ede9fe; color: #6d28d9; }
.badge-nutzer  { background: #e2e8f0; color: #475569; }
.badge-privat  { background: #e2e8f0; color: #475569; }
.badge-geteilt { background: #dbeafe; color: #1d4ed8; }
.badge-warn    { background: #fef3c7; color: #b45309; }

/* ── Dialoge ─────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; z-index: 500; padding: 1rem;
}
.modal {
  background: var(--card); border-radius: var(--radius); padding: 1.5rem;
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
}
.modal h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.25rem; }
.modal-wide { max-width: 620px; }

/* ── Editor ──────────────────────────────────────────────────────────────── */
.editor {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 270px;
  height: calc(100vh - 52px);
}
.editor.no-sidebar { grid-template-columns: 0 minmax(0, 1fr) 270px; }
.editor.no-ways    { grid-template-columns: 240px minmax(0, 1fr) 0; }
.editor.no-sidebar.no-ways { grid-template-columns: 0 minmax(0, 1fr) 0; }

/* Jedes Element bekommt seine Spalte fest zugewiesen. Ohne das rutschen die
   verbleibenden Elemente nach links, sobald eine Spalte mit display:none
   ausgeblendet wird - die Buehne landete dann in der 0 px breiten Spalte und
   war weg, samt der Knoepfe zum Wiedereinblenden. */
.panel-left  { grid-column: 1; }
.stage-wrap  { grid-column: 2; }
.panel-right { grid-column: 3; }

.panel {
  background: var(--card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem .9rem 2rem;
}
.panel-right { border-right: none; border-left: 1px solid var(--border); }
.editor.no-sidebar .panel-left, .editor.no-ways .panel-right { display: none; }

.section { margin-bottom: 1.2rem; }
.section > h3 {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600; margin-bottom: .5rem;
}
.section .btn { width: 100%; margin-bottom: .35rem; }
.section select, .section input[type="text"], .section input[type="number"] {
  width: 100%; padding: .35rem .5rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: .85rem; font-family: inherit; background: var(--card); color: var(--text);
}
.section input[type="range"] { width: 100%; }
.check { display: flex; align-items: center; gap: .45rem; font-size: .85rem; margin-bottom: .3rem; cursor: pointer; }
.check input { width: auto; }
.row { display: flex; gap: .5rem; align-items: center; }
.row > * { flex: 1; }
.row .narrow { flex: 0 0 auto; }

/* Buehne */
.stage-wrap { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
#stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: block;
  touch-action: none;          /* sonst scrollt iPadOS statt zu ziehen */
  user-select: none;
  -webkit-user-select: none;
  outline: none;
}
.stage-bar {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .9rem;
  border-top: 1px solid var(--border);
  background: var(--card);
}
.stage-bar .scene-slider { flex: 1; }
.scene-label { font-size: .9rem; font-weight: 600; min-width: 6.5rem; text-align: right; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 30px; border: 1px solid var(--border); background: var(--card);
  border-radius: 6px; cursor: pointer; font-size: .95rem; color: var(--text); padding: 0;
}
.icon-btn:hover:not(:disabled) { background: var(--bg); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Wege */
.ways-row { display: grid; grid-template-columns: 4.2rem minmax(0,1fr) 4.2rem; gap: .3rem; font-size: .8rem; padding: .1rem 0; }
.ways-row .prev { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.ways-row .next { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.ways-row .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ways-row.head { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .2rem; }
.ways-row.warn .prev, .ways-row.warn .next { color: var(--danger); font-weight: 600; }
.ways-row.hidden-dancer { opacity: .45; }
#note { width: 100%; min-height: 110px; resize: vertical; }

.toolbar { display: flex; align-items: center; gap: .4rem; }
.toolbar .sep { width: 1px; height: 22px; background: var(--border); margin: 0 .2rem; }

.dirty-dot { color: var(--warn); font-weight: 700; }

/* Planliste */
.plan-name { font-weight: 600; }
.plan-name a { color: var(--text); text-decoration: none; }
.plan-name a:hover { color: var(--primary); }
.drop-hint {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 1.5rem; text-align: center; color: var(--muted); font-size: .9rem; margin-top: 1rem;
}
.drop-hint.over { border-color: var(--primary); background: #eff6ff; color: var(--primary); }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

/* ── Schmale Bildschirme (iPad hochkant, Telefon) ────────────────────────── */
@media (max-width: 900px) {
  /* Alle Kombinationen aufzaehlen: die Regeln oben haben mehr Klassen und
     damit hoehere Spezifitaet - eine Media-Query allein schlaegt sie nicht. */
  .editor,
  .editor.no-sidebar,
  .editor.no-ways,
  .editor.no-sidebar.no-ways { grid-template-columns: minmax(0, 1fr); }
  .panel {
    position: fixed; top: 52px; bottom: 0; width: 260px; z-index: 300;
    box-shadow: 0 0 24px rgba(15,23,42,.18);
  }
  /* Schmale Bildschirme: eine Spalte, die Panels liegen als Schubladen darueber. */
  .panel-left, .stage-wrap, .panel-right { grid-column: 1; }
  .panel-left  { left: 0; }
  .panel-right { right: 0; left: auto; border-left: 1px solid var(--border); }
  .editor.no-sidebar .panel-left, .editor.no-ways .panel-right { display: none; }
}
