/* Home-OS · Modul 2 · Anime-Designsystem (Tokens aus dem Styleguide v1.0) */

@font-face { font-family: "Nunito"; font-weight: 700; font-display: swap; src: url("/fonts/nunito-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 800; font-display: swap; src: url("/fonts/nunito-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-display: swap; src: url("/fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-display: swap; src: url("/fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); }


*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-canvas);
  background-image: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 38%, var(--color-canvas) 72%);
  background-attachment: fixed;
}
:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ------------------------------------------------------------ Landschaft */
.scene { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.sun {
  position: absolute; top: 6vh; right: 10vw; width: 140px; height: 140px; border-radius: 50%;
  background: var(--sun-glow);
  opacity: .85;
}
.cloud { position: absolute; fill: var(--cloud); opacity: var(--cloud-opacity); filter: drop-shadow(0 6px 10px rgba(36, 91, 120, .08)); animation: cloud-in 2.4s cubic-bezier(.2, .7, .2, 1) both; }
.cloud-1 { width: 180px; top: 9vh; left: 6vw; }
.cloud-2 { width: 130px; top: 22vh; right: 22vw; animation-delay: .2s; }
.cloud-3 { width: 220px; top: 4vh; left: 46vw; animation-delay: .4s; }
@keyframes cloud-in { from { transform: translateX(-40px); opacity: 0; } }
.hills { filter: blur(var(--hill-blur)); }
.hills { position: absolute; left: 0; bottom: 0; width: 100%; height: 34vh; min-height: 180px; }
.hill-far { fill: var(--hill-far); }
.hill-mid { fill: var(--hill-mid); }
.hill-near { fill: var(--hill-near); }
.tree rect { fill: var(--tree-trunk); }
.tree ellipse { fill: var(--tree-crown); }
.house-roof { fill: var(--house-roof); }
.house-wall { fill: var(--house-wall); }
.house-door { fill: var(--tree-trunk); }
.house-win { fill: var(--house-light); }

/* ------------------------------------------------------------ Layout */
.app { position: relative; z-index: 1; min-height: 100vh; padding: 24px 16px 120px; display: flex; flex-direction: column; align-items: center; outline: none; }
.app-center { justify-content: center; }
.wrap { width: 100%; max-width: 1200px; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: var(--display-weight); font-size: 22px; color: var(--color-text); text-decoration: none; }
.brand-mark { width: 44px; height: 44px; border-radius: 14px; background: var(--color-secondary); display: grid; place-items: center; border: 1px solid var(--color-border); }
.brand-mark svg { width: 28px; height: 28px; }

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-soft);
  padding: 28px 24px;
}
.card-narrow { width: 100%; max-width: 480px; }
.card-wide { width: 100%; max-width: 560px; }
@media (min-width: 640px) { .card { padding: 36px 40px; } }
.fade-in { animation: fade-up .45s ease-out both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(12px); } }

h1, h2, h3, .h1, .h2 { font-family: var(--font-display); font-weight: var(--display-weight); text-shadow: var(--heading-glow); line-height: 1.2; margin: 0; }
.h1 { font-size: 30px; }
.h2 { font-size: 24px; }
@media (min-width: 640px) { .h1 { font-size: 34px; } .h2 { font-size: 26px; } }
.muted { color: var(--color-text-muted); }
p { margin: 8px 0 0; }

.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head .brand { margin-bottom: 18px; }
.auth-head .hero-icon { width: 84px; height: 84px; margin: 0 auto 12px; border-radius: 28px; display: grid; place-items: center; background: var(--color-secondary); }
.auth-head .hero-icon svg { width: 46px; height: 46px; }

/* ------------------------------------------------------------ Formulare */
.form { display: grid; gap: 20px; }
.field { display: grid; gap: 8px; }
.label { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.label-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--color-secondary); flex: none; }
.label-icon svg { width: 22px; height: 22px; }
.label-icon.key { background: var(--color-reward-bg); color: var(--color-sun-700); }
.label-icon.shield { background: var(--color-sky-200); color: var(--color-link); }
.input-row { position: relative; }
.input {
  width: 100%; min-height: 56px; padding: 12px 16px;
  font: inherit; font-size: 18px; color: var(--color-text);
  background: var(--color-input-bg); border: 2px solid var(--color-input-border); border-radius: var(--radius-control);
  transition: border-color .15s;
}
.input:hover { border-color: var(--color-meadow-600); }
.input:focus-visible { border-color: var(--color-link); outline-offset: 2px; }
.input[aria-invalid="true"] { border-color: var(--color-danger); }
.input-row .input { padding-right: 64px; }
.toggle-pw {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border: 0; border-radius: 10px; background: transparent; color: var(--color-text-muted); cursor: pointer; display: grid; place-items: center;
}
.toggle-pw:hover { background: var(--color-soft); color: var(--color-text); }
.toggle-pw svg { width: 24px; height: 24px; }
.hint { font-size: 15px; color: var(--color-text-muted); margin: 0; }
.field-error { display: flex; gap: 8px; align-items: flex-start; color: var(--color-danger); font-weight: 700; font-size: 15px; margin: 0; }
.field-error svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-control); font-weight: 700; }
.notice svg { width: 24px; height: 24px; flex: none; }
.notice-error { background: var(--color-danger-bg); color: var(--color-danger); }
.notice-success { background: var(--color-success-bg); color: var(--color-success); }
.notice-info { background: var(--color-info-bg); color: var(--color-link); border: 1px solid var(--color-sky-200); }
.notice p { margin: 4px 0 0; font-weight: 400; color: var(--color-text); }

/* Avatar-Auswahl */
.avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; border: 0; padding: 0; margin: 0; }
.avatar-grid legend { padding: 0; margin-bottom: 8px; }
.avatar-option { position: relative; }
.avatar-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.avatar-option label {
  display: grid; justify-items: center; gap: 4px; padding: 8px 4px 6px; border-radius: 18px; border: 2px solid transparent;
  background: var(--color-soft); cursor: pointer; font-size: 14px; font-weight: 700; color: var(--color-text-muted);
  transition: transform .15s, border-color .15s, background .15s;
}
.avatar-option label svg { width: 56px; height: 56px; }
.avatar-option label:hover { transform: translateY(-2px); background: var(--color-surface); border-color: var(--color-border); }
.avatar-option input:checked + label { border-color: var(--color-primary); background: var(--color-secondary); color: var(--color-text); box-shadow: var(--shadow-soft); }
.avatar-option input:checked + label::after {
  content: ""; position: absolute; top: 4px; right: 6px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--color-primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/14px no-repeat;
}
.avatar-option input:focus-visible + label { outline: 3px solid var(--color-link); outline-offset: 3px; }

/* ------------------------------------------------------------ Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 12px 22px; border-radius: var(--radius-button); border: 2px solid transparent;
  font: inherit; font-weight: 700; font-size: 18px; line-height: 1.2; cursor: pointer; text-decoration: none;
  transition: background-color .15s, transform .15s, box-shadow .15s;
}
.btn svg { width: 22px; height: 22px; flex: none; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn[disabled], .btn[aria-disabled="true"] { cursor: not-allowed; opacity: .6; transform: none; }
.btn-primary { background: var(--color-primary); color: var(--color-on-primary); box-shadow: var(--shadow-soft); }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-secondary); color: var(--color-text); border-color: var(--color-secondary-border); }
.btn-secondary:hover { background: var(--color-secondary-hover); }
.btn-tertiary { background: transparent; color: var(--color-text); }
.btn-tertiary:hover { background: var(--color-glass); }
.btn-danger { background: var(--color-danger); color: var(--color-on-danger); }
.btn-danger:hover { background: var(--color-danger-hover); }
.btn-big { min-height: 60px; font-size: 20px; width: 100%; }
.btn-sm { min-height: 44px; padding: 8px 14px; font-size: 16px; }
.btn-sm svg { width: 20px; height: 20px; }
.btn-link { background: none; border: 0; color: var(--color-link); text-decoration: underline; text-underline-offset: 4px; font: inherit; font-weight: 700; cursor: pointer; padding: 10px 4px; min-height: 44px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--color-text-muted); font-size: 15px; margin: 6px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--color-border); }

.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .45); border-top-color: currentColor; display: inline-block; animation: spin .8s linear infinite; }
.loading { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 0; font-weight: 700; }
.loading .spinner { border-color: var(--color-secondary); border-top-color: var(--color-primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ Dashboard */
.topbar {
  width: 100%; max-width: 1200px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 20px; background: var(--color-glass); border: 1px solid var(--color-border);
  border-radius: 20px; box-shadow: var(--shadow-soft);
}
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.me-chip { color: var(--color-text); border: 2px solid transparent; font: inherit; cursor: pointer; min-height: 48px; display: inline-flex; align-items: center; gap: 8px; padding: 4px 14px 4px 4px; border-radius: 999px; background: var(--color-soft); font-weight: 700; }
.me-chip svg { width: 40px; height: 40px; }

.hero { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding: 28px 24px; margin-bottom: 24px; position: relative; overflow: hidden; }
.hero-avatar { width: 112px; height: 112px; flex: none; animation: pop-in .6s cubic-bezier(.3, 1.5, .5, 1) both; }
.hero-avatar svg { width: 100%; height: 100%; }
@keyframes pop-in { from { transform: scale(.3) rotate(-12deg); opacity: 0; } }
.hero-text { flex: 1; min-width: 220px; }
.welcome { font-size: 34px; display: flex; flex-wrap: wrap; align-items: baseline; }
@media (min-width: 640px) { .welcome { font-size: 44px; } }
.welcome .ch { display: inline-block; white-space: pre; animation: letter-in .5s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: calc(var(--i) * 45ms + .25s); }
@keyframes letter-in { from { transform: translateY(18px) scale(.6); opacity: 0; } }
.sparkle-wrap { position: absolute; inset: 0; pointer-events: none; }
.sparkle { position: absolute; width: 22px; height: 22px; color: var(--color-sun-700); opacity: 0; animation: twinkle 1.6s ease-in-out 3 both; }
.sparkle svg { width: 100%; height: 100%; fill: var(--color-sun-200); stroke: var(--color-sun-700); }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(.4) rotate(0); } 50% { opacity: 1; transform: scale(1) rotate(25deg); } }
.seed { position: absolute; bottom: -10px; width: 10px; height: 10px; border-radius: 50%; background: var(--seed); box-shadow: 0 0 10px 3px var(--seed-glow); opacity: 0; animation: seed-up 3.6s ease-out both; }
@keyframes seed-up { 10% { opacity: 1; } 100% { transform: translate(var(--dx, 20px), -220px); opacity: 0; } }

.section-title { display: flex; align-items: center; gap: 10px; margin: 8px 4px 14px; font-size: 22px; }
.section-title svg { width: 26px; height: 26px; }

.modules { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .modules { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .modules { grid-template-columns: repeat(4, 1fr); } }
.module {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-card); box-shadow: var(--shadow-soft);
  padding: 22px; display: flex; flex-direction: column; gap: 14px; animation: fade-up .5s ease-out both; animation-delay: calc(var(--i) * 90ms + .5s);
}
.module-icon { width: 76px; height: 76px; border-radius: 24px; display: grid; place-items: center; }
.module-icon svg { width: 42px; height: 42px; }
.tone-wood { background: var(--color-wood-200); color: var(--color-wood-700); }
.tone-sky { background: var(--color-sky-200); color: var(--color-link); }
.tone-sun { background: var(--color-sun-200); color: var(--color-sun-700); }
.tone-meadow { background: var(--color-secondary); color: var(--color-meadow-600); }
.module h3 { font-size: 24px; }
.module .sub { margin: 2px 0 0; color: var(--color-text-muted); font-size: 16px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 15px; font-weight: 700; width: fit-content; }
.badge svg { width: 18px; height: 18px; }
.badge-soon { background: var(--color-reward-bg); color: var(--color-sun-700); }
.badge-active { background: var(--color-success-bg); color: var(--color-success); }
.badge-pending { background: var(--color-reward-bg); color: var(--color-sun-700); }
.badge-admin { background: var(--color-sky-200); color: var(--color-link); }
.module .btn { margin-top: auto; }
.module.is-ready { border: 2px solid var(--color-secondary-border); }
a.btn { text-decoration: none; }

.parent-zone { margin-top: 28px; padding: 18px 20px; border-radius: var(--radius-card); background: var(--color-glass); border: 2px dashed var(--color-secondary-border); display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.parent-zone .t { display: flex; align-items: center; gap: 12px; }
.parent-zone .t svg { width: 32px; height: 32px; color: var(--color-link); }

/* ------------------------------------------------------------ Admin */
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.user-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.user-row {
  display: grid; grid-template-columns: 64px 1fr; gap: 12px 16px; align-items: center; padding: 16px; border-radius: var(--radius-card);
  border: 1px solid var(--color-border); background: var(--color-surface);
}
.user-row.is-pending { background: var(--color-pending-bg); border-color: var(--color-pending-border); }
.user-row .ava svg { width: 64px; height: 64px; }
.user-row .who strong { font-family: var(--font-display); font-size: 20px; display: block; }
.user-row .who .meta { font-size: 15px; color: var(--color-text-muted); }
.user-row .state { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.user-row .actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (min-width: 820px) {
  .user-row { grid-template-columns: 64px 1fr auto; }
  .user-row .actions { grid-column: auto; justify-content: flex-end; }
}
.select { min-height: 44px; padding: 8px 12px; border-radius: var(--radius-control); border: 2px solid var(--color-input-border); font: inherit; font-size: 16px; background: var(--color-input-bg); color: var(--color-text); }
.empty { text-align: center; padding: 28px 12px; }
.empty svg { width: 64px; height: 64px; color: var(--color-meadow-600); }

/* ------------------------------------------------------------ Dialog */
.dialog { border: 0; padding: 0; border-radius: var(--radius-panel); box-shadow: var(--shadow-lift); max-width: min(440px, calc(100vw - 32px)); color: var(--color-text); background: var(--color-surface); }
.dialog::backdrop { background: rgba(36, 61, 50, .35); }
.dialog-inner { padding: 28px 24px; margin: 0; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 22px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20; max-width: calc(100vw - 32px); box-shadow: var(--shadow-lift); animation: fade-up .3s ease-out both; }

/* ------------------------------------------------------------ Bewegung reduzieren */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .sparkle, .seed { display: none; }
}

/* ------------------------------------------------------------ Profil / Theme-Auswahl */
.me-chip:hover { border-color: var(--color-secondary-border); }
.me-chip svg:last-child { width: 22px; height: 22px; color: var(--color-text-muted); }
.dialog { max-height: calc(100vh - 32px); overflow: auto; }
.dialog-wide { max-width: min(720px, calc(100vw - 32px)); width: 100%; }
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.profile-head svg { width: 64px; height: 64px; flex: none; }
.theme-grid { display: grid; gap: 12px; grid-template-columns: 1fr; border: 0; padding: 0; margin: 0; }
@media (min-width: 560px) { .theme-grid { grid-template-columns: repeat(2, 1fr); } }
.theme-grid legend { padding: 0; margin-bottom: 10px; }
.theme-option { position: relative; }
.theme-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.theme-card {
  display: grid; gap: 10px; padding: 14px; cursor: pointer; min-height: 132px;
  background-color: var(--color-canvas);
  background-image: linear-gradient(180deg, var(--bg-top), var(--bg-mid) 55%, var(--color-canvas));
  color: var(--color-text); border: 3px solid var(--color-border); border-radius: var(--radius-card);
  font-family: var(--font-body); transition: transform .15s, border-color .15s;
}
.theme-card:hover { transform: translateY(-2px); }
.theme-card .tname { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 20px; text-shadow: var(--heading-glow); }
.theme-card .tdesc { font-size: 15px; color: var(--color-text-muted); margin: 0; }
.theme-card .swatches { display: flex; gap: 6px; align-items: center; }
.theme-card .swatches span { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--color-surface); }
.theme-card .swatches .s1 { background: var(--color-primary); }
.theme-card .swatches .s2 { background: var(--color-surface); border-color: var(--color-border); }
.theme-card .swatches .s3 { background: var(--color-sun-700); }
.theme-card .swatches .s4 { background: var(--hill-mid); }
.theme-card .demo-btn { justify-self: start; padding: 6px 12px; border-radius: var(--radius-button); background: var(--color-primary); color: var(--color-on-primary); font-weight: 700; font-size: 14px; }
.theme-option input:checked + .theme-card { border-color: var(--color-focus); box-shadow: var(--shadow-lift); }
.theme-option input:checked + .theme-card .tname::after { content: " ✓"; }
.theme-option input:focus-visible + .theme-card { outline: 3px solid var(--color-focus); outline-offset: 3px; }
