/* ====== Theme / Basis ====== */
:root{
  --bg: #0b1220;
  --panel: #101a2f;
  --panel2:#0f1830;
  --text:#eaf0ff;
  --muted:#b8c4ea;
  --border: rgba(255,255,255,.12);
  --accent:#7aa2ff;
  --accent2:#8cf0d1;
  --danger:#ff6b6b;
  --focus:#ffd36a;

  --radius: 16px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --max: 1200px;
  --gap: 14px;

  color-scheme: dark;
}

*{ box-sizing: border-box; }
html, body{ height:100%; }
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 800px at 20% 0%, rgba(122,162,255,.18), transparent 60%),
              radial-gradient(900px 700px at 90% 10%, rgba(140,240,209,.14), transparent 55%),
              var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Skip-Link */
.skip-link{
  position:absolute;
  left:-9999px;
  top: 10px;
  padding:10px 12px;
  background: var(--panel);
  color: var(--text);
  border:1px solid var(--border);
  border-radius: 10px;
  z-index: 999;
}
.skip-link:focus{ left: 10px; outline: 3px solid var(--focus); }

/* Fokus sichtbar */
:focus-visible{
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Header */
.app-header{
  position: sticky;
  top:0;
  z-index: 10;
  backdrop-filter: blur(10px);
  background: rgba(11,18,32,.75);
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
}
.app-header > *{
  max-width: var(--max);
  margin: 0 auto;
}
.brand{
  display:flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}
.logo{
  display:inline-flex;
  width: 44px; height:44px;
  align-items:center; justify-content:center;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(122,162,255,.22), rgba(140,240,209,.12));
  border: 1px solid var(--border);
}
.app-title{ font-size: 1.15rem; margin:0; }
.app-subtitle{ margin:.15rem 0 0; color: var(--muted); font-size: .95rem; }

.toolbar{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items:center;
}

/* Layout */
.layout{
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px;
  display:grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}

/* Panels */
.panel{
  background: linear-gradient(180deg, rgba(16,26,47,.92), rgba(16,26,47,.82));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.panel-head{
  display:flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.panel-title{
  font-size: 1.05rem;
  margin:0;
}
.subhead{
  margin: 0 0 10px;
  font-size: 1rem;
}
.sep{
  border:0;
  height:1px;
  background: var(--border);
  margin: 14px 0;
}

/* Forms */
.field{ margin: 10px 0; }
label{ display:block; margin-bottom: 6px; color: var(--muted); }
input, textarea{
  width: 100%;
  font: inherit;
  color: var(--text);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  padding: 10px 12px;
}
textarea{ resize: vertical; min-height: 120px; }
.field.inline label{ margin:0 0 6px; }
.field.inline input{ max-width: 520px; }

.muted{ color: var(--muted); }
.hint{ font-size: .92rem; margin-top: 10px; }
kbd{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: .9em;
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
}

/* Buttons */
.btn{
  appearance: none;
  border: 1px solid rgba(122,162,255,.35);
  background: linear-gradient(180deg, rgba(122,162,255,.18), rgba(122,162,255,.10));
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  display:inline-flex;
  gap: 8px;
  align-items:center;
  justify-content:center;
  min-height: 40px;
}
.btn:hover{ border-color: rgba(122,162,255,.55); }
.btn:active{ transform: translateY(1px); }

.btn-ghost{
  border-color: rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
}
.btn-small{
  padding: 8px 10px;
  min-height: 34px;
  border-radius: 10px;
  font-size: .95rem;
}
.icon-btn{
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  border-radius: 12px;
  width: 40px; height: 40px;
  cursor: pointer;
}

/* “File”-Label als Button */
.filelike{ user-select:none; }

/* Lists */
.chapter-list, .snippet-list, .project-list{
  list-style: none;
  padding: 0;
  margin: 0;
  display:flex;
  flex-direction: column;
  gap: 8px;
}

.item{
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.05);
  border-radius: 14px;
  padding: 10px;
}
.item[aria-current="true"]{
  border-color: rgba(140,240,209,.55);
  box-shadow: 0 0 0 2px rgba(140,240,209,.15);
}
.item-head{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
}
.item-title{
  margin:0;
  font-size: 1rem;
}
.item-meta{
  margin: 4px 0 0;
  font-size: .9rem;
  color: var(--muted);
}
.item-actions{
  display:flex;
  gap: 8px;
  align-items:center;
}
.linkbtn{
  appearance:none;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
  color: var(--text);
  border-radius: 10px;
  padding: 6px 10px;
  cursor:pointer;
}

/* Editor */
.editor-panel{ padding-bottom: 10px; }
.editor-head{
  align-items:flex-start;
}
.editor-meta{
  display:flex;
  flex-direction: column;
  gap: 10px;
}
.editor-actions{
  display:flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items:center;
  justify-content:flex-end;
}

/* Statusbar */
.statusbar{
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 10px;
  display:flex;
  flex-direction: column;
  gap: 10px;
}
.stats{ display:flex; flex-wrap: wrap; gap: 10px; align-items:center; }
.dot{ opacity: .6; }

.saveinfo{
  display:flex;
  gap: 10px;
  align-items:center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.pill{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
  min-height: 32px;
}
.pill.ok{ border-color: rgba(140,240,209,.55); }
.pill.warn{ border-color: rgba(255,211,106,.6); }
.pill.bad{ border-color: rgba(255,107,107,.6); }

.row{
  display:flex;
  gap: 10px;
  align-items:center;
}
.wrap{ flex-wrap: wrap; }

/* Dialog */
.dlg{
  width: min(720px, calc(100% - 18px));
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(16,26,47,.96);
  box-shadow: var(--shadow);
  padding: 0;
}
.dlg::backdrop{ background: rgba(0,0,0,.55); }
.dlg-inner{ padding: 14px; }
.dlg-head{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
}
.dlg-body{ margin-top: 10px; }
.dlg-foot{
  display:flex;
  justify-content:flex-end;
  gap: 10px;
  margin-top: 12px;
}

details summary{ cursor: pointer; }

/* Screenreader-only */
.sr-only{
  position:absolute !important;
  width:1px; height:1px;
  padding:0; margin:-1px;
  overflow:hidden; clip: rect(0,0,0,0);
  white-space:nowrap; border:0;
}

/* Responsive (progressive) */
@media (min-width: 960px){
  .layout{
    grid-template-columns: 360px 1fr;
    align-items:start;
  }
  .sidebar{ position: sticky; top: 118px; height: fit-content; }
  .statusbar{
    flex-direction: row;
    align-items:center;
    justify-content: space-between;
  }
}
