:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface2: #f0f4f8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --accent2: #0ea5e9;
  --accent-soft: #e0f2fe;
  --warn: #ef4444;
  --warn-soft: #fef2f2;
  --ok: #10b981;
  --ok-soft: #d1fae5;
  --text: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.08);
  --shadow-lg: 0 12px 32px rgba(15,23,42,0.12);
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
}

/* ── HEADER ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px 12px 74px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 50;
  margin-left: -56px;
}

/* ── KEBAB MENU ── */
.kebab-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  width: 38px; height: 38px;
  border-radius: 10px;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.kebab-btn:active, .kebab-btn:hover { background: var(--surface2); border-color: var(--accent); color: var(--accent); }
.kebab-menu {
  display: none;
  position: fixed;
  top: 64px; right: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 250;
  min-width: 250px;
  padding: 6px;
  flex-direction: column;
}
.kebab-menu.open { display: flex; }
.kebab-item {
  background: transparent;
  border: none;
  text-align: left;
  padding: 11px 14px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
  width: 100%;
}
.kebab-item:hover, .kebab-item:active { background: var(--surface2); }
.kebab-sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* ── SIDEBAR ── */
body { padding-left: 56px; }
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 56px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 70px;
  gap: 4px;
  z-index: 60;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 0; }
.sidebar-item {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  text-decoration: none;
  flex-shrink: 0;
}
.sidebar-item:hover { background: var(--surface2); transform: scale(1.05); }
.sidebar-item:active { background: var(--surface2); }
.sidebar-item.active { background: var(--accent-soft); }
.sidebar-preview {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 4px 12px rgba(2,132,199,0.25);
}
.sidebar-preview:hover, .sidebar-preview:active {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  transform: scale(1.05);
  color: #fff;
}
.sidebar-divider {
  width: 28px;
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}
.header-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
header h1 { font-family: var(--sans); font-size: 16px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); text-transform: none; }
header p { font-size: 12px; color: var(--text-muted); margin-top: 2px; font-family: var(--sans); }
.header-time { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--text-dim); white-space: nowrap; }

/* ── MAIN LAYOUT ── */
.main {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── OUTPUT ── */
#output-text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-family: var(--sans);
  font-size: 14px; line-height: 1.7;
  color: var(--text); white-space: pre-wrap;
  min-height: 80px;
  max-height: 60vh;
  overflow-y: auto;
}
#output-text.empty { color: var(--text-dim); font-style: italic; font-size: 13px; }

.btn-row {
  display: flex; gap: 8px;
  padding: 10px 16px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.btn {
  flex: 1 1 calc(50% - 6px); padding: 11px 8px;
  border-radius: 8px; border: none;
  cursor: pointer; font-family: var(--mono);
  font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.04em; transition: all 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
}
.btn-secondary { background: var(--surface2); border: 1px solid var(--border); color: var(--text-muted); }
.btn-secondary:active { background: var(--border); }
.btn-copy { background: var(--surface2); border: 1px solid var(--border); color: var(--text-muted); }
.btn-copy:active { background: var(--border); }
.btn-copy.copied { background: rgba(104,211,145,0.1); border-color: var(--ok); color: var(--ok); }
.pat-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 2px;
}
.btn-qr { background: var(--surface2); border: 1px solid var(--border); color: var(--text-muted); }

/* ── ACCORDION SECTIONS ── */
.sections { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}
.section.open { box-shadow: var(--shadow-md); }

.section-header {
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  background: transparent;
  transition: background 0.15s;
}
.section-header:active { background: var(--surface2); }
.section.open .section-header { border-bottom: 1px solid var(--border); }

.section-header > span:first-child {
  font-size: 22px;
  line-height: 1;
}
.section-header-text {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  flex: 1;
}

.section-chevron {
  color: var(--text-dim); font-size: 13px;
  transition: transform 0.25s;
  flex-shrink: 0;
}
.section.open .section-chevron { transform: rotate(180deg); }

.section-badge {
  background: var(--accent);
  color: #ffffff;
  font-family: var(--mono);
  font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 10px;
  display: none;
}
.section-badge.visible { display: inline-block; }

.section-body {
  display: none;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  flex-direction: column; gap: 10px;
}
.section.open .section-body { display: flex; }

/* ── TOGGLE BUTTONS ── */
.group-label {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: 0;
}

.atemzeichen-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  flex-wrap: wrap;
}
.atemzeichen-label {
  font-size: 13.5px;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.alpha-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.alpha-btn {
  aspect-ratio: 1;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: all 0.12s;
  box-shadow: var(--shadow-sm);
}
.alpha-btn:active { opacity: 0.7; }
.alpha-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.toggle-group { display: flex; flex-wrap: wrap; gap: 6px; }
.toggle-btn {
  padding: 7px 13px;
  border-radius: 8px; border: 1px solid var(--border-strong);
  font-size: 13px; cursor: pointer;
  font-family: var(--sans); font-weight: 500;
  color: var(--text); background: var(--surface);
  transition: all 0.12s; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: var(--shadow-sm);
}
.toggle-btn:active { opacity: 0.7; }
.toggle-btn.active { background: var(--accent); border-color: var(--accent); color: #ffffff; font-weight: 600; }
.toggle-btn.active-warn { background: var(--warn); border-color: var(--warn); color: #ffffff; font-weight: 600; }

/* ── RADIO BUTTONS ── */
.radio-group { display: flex; flex-wrap: wrap; gap: 6px; }
.radio-btn {
  padding: 7px 13px;
  border-radius: 8px; border: 1px solid var(--border-strong);
  font-size: 13px; cursor: pointer;
  font-family: var(--sans); font-weight: 500;
  color: var(--text); background: var(--surface);
  transition: all 0.12s; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: var(--shadow-sm);
}
.radio-btn:active { opacity: 0.7; }
.radio-btn.active { background: var(--accent); border-color: var(--accent); color: #ffffff; font-weight: 600; }

/* ── CHECKBOXES ── */
.check-item {
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; padding: 10px 8px;
  border-radius: 8px; transition: background 0.12s; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.check-item:active { background: rgba(255,255,255,0.06); }
.check-item input[type="checkbox"] { display: none; }
.checkmark {
  width: 22px; height: 22px; flex-shrink: 0;
  border: 1.5px solid var(--border-strong); border-radius: 6px;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s; font-size: 13px;
  color: transparent;
}
.check-item input:checked ~ .checkmark { background: var(--accent); border-color: var(--accent); color: #ffffff; }
.check-label { font-size: 14px; color: var(--text); line-height: 1.3; }
.check-item input:checked ~ .check-label { color: var(--text); font-weight: 600; }

/* ── INPUTS ── */
.input-row { display: flex; align-items: center; gap: 10px; }
.input-row label { font-size: 13px; color: var(--text-muted); font-family: var(--sans); white-space: nowrap; min-width: 50px; font-weight: 500; }
.input-row input {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px; color: var(--text);
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  padding: 8px 12px; outline: none;
  transition: all 0.15s; width: 90px;
  -webkit-appearance: none;
}
.input-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-row input::placeholder { color: var(--text-dim); }
.input-row span { font-size: 13px; color: var(--text-muted); font-family: var(--sans); }

.textarea-group { display: flex; flex-direction: column; gap: 6px; }
.textarea-group label { font-size: 12px; color: var(--text-muted); font-family: var(--sans); font-weight: 600; letter-spacing: 0; text-transform: none; }
.textarea-group textarea {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px; color: var(--text);
  font-family: var(--sans); font-size: 14px;
  padding: 10px 12px; outline: none;
  transition: all 0.15s; resize: vertical;
  -webkit-appearance: none;
}
.textarea-group textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea-group textarea::placeholder { color: var(--text-dim); }

.divider { height: 1px; background: var(--border); }

/* ── RESPONSIVE ── */
@media (min-width: 600px) and (max-width: 1023px) {
  .sections { padding: 16px 24px; max-width: 720px; margin: 0 auto; width: 100%; }
  .alpha-grid { grid-template-columns: repeat(13, 1fr); }
  .check-label, .toggle-btn, .radio-btn { font-size: 14px; }
}

@media (min-width: 1024px) {
  .sections { padding: 18px 32px; max-width: 900px; margin: 0 auto; }
  .section-header:hover { background: rgba(8,145,178,0.08); }
  .toggle-btn:hover { border-color: var(--accent); color: var(--accent); }
  .radio-btn:hover { border-color: var(--accent2); color: var(--accent2); }
  .alpha-btn:hover { border-color: var(--accent2); color: var(--accent2); }
}

@media (min-width: 1440px) {
  .alpha-grid { grid-template-columns: repeat(13, 1fr); }
}
