:root{
  color-scheme: light;
  --bg:#f6f7fb;
  --bg-grad-start:#eef2ff;
  --bg-grad-end:#f8fafc;
  --card:#ffffff;
  --text:#111827;
  --muted:#6b7280;
  --primary:#2563eb;
  --primary-600:#1d4ed8;
  --border:#e5e7eb;
  --input-bg:#ffffff;
  --input-text:#111827;
  --radius:16px;
  --shadow:0 10px 20px rgba(0,0,0,.05);
}

/* Dark Theme Overrides */
:root.dark{
  color-scheme: dark;
  --bg:#0b1220;
  --bg-grad-start:#0b1220;
  --bg-grad-end:#0f172a;
  --card:#0f172a;
  --text:#e5e7eb;
  --muted:#94a3b8;
  --primary:#3b82f6;
  --primary-600:#2563eb;
  --border:#233044;
  --input-bg:#111827;
  --input-text:#e5e7eb;
  --shadow:0 10px 20px rgba(0,0,0,.35);
}

*{box-sizing:border-box}
[hidden]{display:none !important;}

body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,"Noto Sans","Helvetica Neue",sans-serif;
  color:var(--text);
  background:linear-gradient(180deg, var(--bg-grad-start), var(--bg-grad-end) 40%);
  padding:1rem;
}

/* Theme toggle (oben rechts) */
.topbar{
  position:fixed;
  right:12px;
  top:10px;
  z-index:1000;
}
.switch{
  display:inline-flex; align-items:center; gap:.5rem;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:999px;
  padding:.3rem .5rem .3rem .6rem;
  box-shadow:var(--shadow);
}
.switch input{ display:none; }
.switch .slider{
  width:44px; height:24px; border-radius:999px;
  background:var(--border); position:relative; transition:background .2s ease;
}
.switch .slider::after{
  content:"";
  position:absolute; top:2px; left:2px;
  width:20px; height:20px; border-radius:50%;
  background:#fff; transition:transform .2s ease;
  box-shadow:0 2px 6px rgba(0,0,0,.2);
}
.switch input:checked + .slider{ background:var(--primary); }
.switch input:checked + .slider::after{ transform:translateX(20px); }
.switch .switch-text{ font-weight:700; min-width:1.5rem; text-align:center; }

/* Layout */
.container{ max-width:820px; margin:0 auto; }

h1{
  margin:0 0 1rem;
  text-align:center;
  font-size:clamp(1.4rem,3.2vw,2rem);
}

.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:1rem;
  margin:1rem 0;
  box-shadow:var(--shadow);
}

.field{ display:flex; flex-direction:column; }
label{ font-weight:600; margin:.6rem 0 .35rem; }

input, select, button{ font:inherit; }
input, select{
  width:100%; padding:.7rem .8rem;
  border:1px solid var(--border); border-radius:12px;
  background:var(--input-bg); color:var(--input-text);
  min-height:44px;
}
input[disabled]{ background:rgba(127,127,127,.12); color:var(--muted); }

.fieldset{
  display:flex; gap:.6rem; flex-wrap:wrap;
  border:none; padding:0; margin:.5rem 0 .2rem 0;
}
.pill{
  display:inline-flex; align-items:center; gap:.5rem;
  padding:.3rem .6rem; border:1px solid var(--border); border-radius:999px;
}

.muted{ color:var(--muted); font-weight:500; }
.result{ margin-top:1rem; font-weight:800; font-size:1.1rem; text-align:center; min-height:1.6em; }

.actions{ display:flex; gap:.6rem; flex-wrap:wrap; margin-top:.8rem; }
button{
  padding:.8rem 1.1rem; min-height:44px;
  border:none; border-radius:12px; color:#fff; background:var(--primary);
  font-weight:700; cursor:pointer; transition:transform .03s ease, background .2s ease, opacity .2s ease;
}
button:hover{ background:var(--primary-600); }
button:active{ transform:translateY(1px); }
button.ghost{ background:rgba(127,127,127,.12); color:var(--text); border:1px solid var(--border); }
button.ghost:hover{ opacity:.95; }

/* Grid */
.grid-2{ display:grid; gap:.8rem; }
@media (min-width:640px){
  body{ padding:2rem 1.25rem; }
  .card{ padding:1.2rem; }
  .grid-2{ grid-template-columns:repeat(2,minmax(0,1fr)); align-items:end; }
  .actions{ justify-content:flex-end; }
}
