:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #dfe2e7;
  --text: #1d2330;
  --muted: #6a7282;
  --accent: #2f6fde;
  --accent-soft: #e6eefc;
  --danger: #c93b3b;
  --ok: #2c8a4b;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: .5em .9em; border-radius: 8px; display: inline-flex; align-items: center; gap: .4em; text-decoration: none;
}
button:hover, .btn:hover { border-color: #b8bfca; background: #fafbfc; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #255ec4; }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

input, select { font: inherit; padding: .5em .6em; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: .85rem; color: var(--muted); margin: .7em 0 .25em; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; }
.error { color: var(--danger); min-height: 1.2em; margin: .6em 0 0; font-size: .9rem; }

/* ---------- Startseite */
.auth { max-width: 380px; margin: 10vh auto; }
.auth .tabs { display: flex; gap: .4rem; margin-bottom: 1rem; }
.auth .tabs button { flex: 1; justify-content: center; }
.auth form button[type=submit] { width: 100%; justify-content: center; margin-top: 1.2rem; }
.logo { font-weight: 700; font-size: 1.25rem; display: flex; align-items: center; gap: .5rem; }
.logo svg { width: 28px; height: 28px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1.4rem; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar .right { display: flex; gap: .5rem; align-items: center; }
.page { max-width: 1000px; margin: 1.5rem auto; padding: 0 1.2rem; display: grid; gap: 1.2rem; }

.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .8rem; }
.project { display: flex; flex-direction: column; gap: .3rem; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; cursor: pointer; }
.project:hover { border-color: var(--accent); }
.project .name { font-weight: 600; }
.project .actions { display: flex; gap: .3rem; margin-top: .5rem; }
.project .actions button { padding: .25em .55em; font-size: .85rem; }
.project.new { align-items: center; justify-content: center; border-style: dashed; color: var(--accent); font-weight: 600; min-height: 110px; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45em .5em; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; }
code { font-family: ui-monospace, Consolas, monospace; background: var(--bg); padding: .1em .35em; border-radius: 4px; }
.row { display: flex; gap: .6rem; align-items: end; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 120px; }
.badge { font-size: .75rem; background: var(--accent-soft); color: var(--accent); padding: .1em .45em; border-radius: 999px; }

/* ---------- Editor */
.editor { display: grid; grid-template-rows: auto 1fr; height: 100vh; }
.editor .topbar { padding: .5rem .8rem; }
.editor .topbar input.title { width: 240px; font-weight: 600; border-color: transparent; }
.editor .topbar input.title:hover, .editor .topbar input.title:focus { border-color: var(--line); }
.workspace { display: grid; grid-template-columns: 150px 1fr 270px; min-height: 0; }
.shapes { background: var(--panel); border-right: 1px solid var(--line); padding: .7rem; overflow-y: auto; display: flex; flex-direction: column; gap: .4rem; }
.shapes button { flex-direction: column; justify-content: center; padding: .5rem .3rem; font-size: .85rem; }
.shapes button svg { width: 36px; height: 36px; }
.view { position: relative; min-width: 0; min-height: 0; }
.view canvas { display: block; width: 100%; height: 100%; outline: none; }
.toolbar { position: absolute; top: .7rem; left: 50%; transform: translateX(-50%); display: flex; gap: .3rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .3rem; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.toolbar button { padding: .4em .65em; font-size: .9rem; }
.toolbar .sep { width: 1px; background: var(--line); margin: 0 .15rem; }
.hint { position: absolute; bottom: .7rem; left: .8rem; font-size: .8rem; color: var(--muted); background: rgba(255,255,255,.85); padding: .3rem .6rem; border-radius: 6px; }
.props { background: var(--panel); border-left: 1px solid var(--line); padding: .9rem; overflow-y: auto; }
.props .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
.props .grid3 label { margin: 0 0 .15rem; text-align: center; font-weight: 600; }
.props .grid3 input { padding: .4em .3em; text-align: center; }
.props section { padding-bottom: .9rem; margin-bottom: .9rem; border-bottom: 1px solid var(--line); }
.props section:last-child { border-bottom: 0; }
.kind { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; }
.kind button { justify-content: center; }
.colors { display: flex; flex-wrap: wrap; gap: .3rem; }
.colors button { width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.colors button.active { box-shadow: 0 0 0 2px var(--accent); }
.check { display: flex; align-items: center; gap: .5rem; margin: .5rem 0; font-size: .9rem; color: var(--text); }
.check input { width: auto; }
.list { display: flex; flex-direction: column; gap: 2px; max-height: 200px; overflow-y: auto; }
.list button { justify-content: space-between; border: 0; padding: .35em .5em; font-size: .9rem; border-radius: 6px; }
.list button.sel { background: var(--accent-soft); color: var(--accent); }
.status { font-size: .8rem; color: var(--muted); }

dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; max-width: 440px; }
dialog::backdrop { background: rgba(20,25,35,.35); }
dialog .buttons { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.2rem; }

#toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%) translateY(150%); background: #1d2330; color: #fff; padding: .6rem 1rem; border-radius: 8px; transition: transform .25s; z-index: 99; font-size: .9rem; }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); }
#toast.ok { background: var(--ok); }

#busy { position: fixed; inset: 0; background: rgba(255,255,255,.6); display: none; align-items: center; justify-content: center; z-index: 98; font-weight: 600; }
#busy.show { display: flex; }

@media (max-width: 820px) {
  .workspace { grid-template-columns: 90px 1fr; }
  .props { grid-column: 1 / -1; max-height: 40vh; border-left: 0; border-top: 1px solid var(--line); }
  .workspace { grid-template-rows: 1fr auto; }
  .shapes button span { font-size: .7rem; }
}

/* ---------- Hilfe & Tutorial */
.help-list { padding-left: 1.1rem; margin: 0 0 .8rem; line-height: 1.55; font-size: .92rem; }
dialog h3 { margin: .9rem 0 .3rem; }
body.tutorial .hint { display: none; }
.tut-ring {
  position: fixed; z-index: 90; pointer-events: none; display: none; border: 3px solid var(--accent); border-radius: 12px;
  box-shadow: 0 0 0 4px rgba(47,111,222,.25); animation: tut-pulse 1.4s ease-in-out infinite;
  transition: left .2s, top .2s, width .2s, height .2s;
}
@keyframes tut-pulse { 50% { box-shadow: 0 0 0 10px rgba(47,111,222,.08); } }
.tut-card {
  position: fixed; z-index: 91; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: .9rem 1.1rem 1rem; box-shadow: 0 10px 30px rgba(20,25,35,.18);
}
.tut-card h2 { margin: .5rem 0 .35rem; }
.tut-text { font-size: .95rem; line-height: 1.5; }
.tut-head { display: flex; justify-content: space-between; align-items: center; }
.tut-step { font-size: .8rem; color: var(--muted); }
.tut-close { padding: .2em .55em; font-size: .8rem; border-color: transparent; color: var(--muted); }
.tut-bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: .4rem; overflow: hidden; }
.tut-bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.tut-warn { background: #fff4dc; border-radius: 8px; padding: .45rem .6rem; margin: .6rem 0 0; font-size: .9rem; }
.tut-ok { color: var(--ok); }
.tut-buttons { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .8rem; }
.tut-buttons:empty { display: none; }
.project.tutorial-tile { align-items: center; justify-content: center; text-align: center; border-style: dashed; min-height: 110px; }
