/* ===== Base ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 24px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ===== Layout ===== */
.app {
  max-width: 560px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-8);
}

/* ===== App-Header (Design-System §7.3) ===== */
.app-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
}
.app-header-title {
  display: flex; align-items: center; gap: var(--space-2);
  min-width: 0; flex: 1 1 auto;
}
.app-header-icon { display: inline-flex; flex-shrink: 0; }
.app-header-icon img {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: block;
}
.app-header-title h1 {
  font-family: 'Figtree', system-ui, sans-serif;
  font-size: 22px; line-height: 28px; font-weight: 800;
  color: var(--text); letter-spacing: -0.01em; margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-header-actions {
  display: flex; align-items: center;
  gap: var(--space-2); flex-shrink: 0;
}
.app-header-status {
  position: absolute;
  bottom: -9px; right: 0;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 10px; line-height: 14px; font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.25s, background-color 0.2s, border-color 0.2s, color 0.2s;
}
.app-header-status[hidden]                 { display: none; }
.app-header-status[data-status="offline"]  { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.app-header-status[data-status="pending"]  { background: var(--info-bg);    border-color: var(--info-border);    color: var(--info-text); }
.app-header-status[data-status="saved"]    { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.app-header-status[data-status="error"]    { background: var(--error-bg);   border-color: var(--error-border);   color: var(--error-text); }

/* ===== Pills (Design-System §7.1) ===== */
.btn-pill {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-pill);
  padding: 0 var(--space-3);
  min-height: 44px; min-width: 44px;
  font-size: 14px; font-weight: 600;
  font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-1);
  cursor: pointer;
  white-space: nowrap; flex-shrink: 0;
  transition: background-color 0.15s;
}
.btn-pill:hover  { background: var(--surface-hover); }
.btn-pill:active { background: var(--surface-active); }

/* ===== Icon-Buttons (Design-System §7.4) ===== */
.icon-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  background: transparent; border: none;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  cursor: pointer;
}
.icon-btn:hover         { background: var(--surface-hover); color: var(--text); }
.icon-btn.danger        { color: var(--error-text); }
.icon-btn.danger:hover  { background: var(--error-bg); }
.item-actions {
  display: flex; gap: 2px; flex-shrink: 0; margin-left: auto;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  font-size: 15px; font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary {
  background: var(--action); color: var(--on-action);
  border-color: var(--action);
}
.btn-primary:hover  { background: var(--action-hover); border-color: var(--action-hover); }
.btn-accent {
  background: var(--accent-solid); color: var(--on-accent);
  border-color: var(--accent-solid);
}
.btn-accent:hover            { background: var(--a-800); border-color: var(--a-800); }
[data-theme="dark"]
  .btn-accent:hover          { background: var(--a-200); border-color: var(--a-200); }
.btn-ghost {
  background: transparent; color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover  { background: var(--surface-hover); }
.btn-danger {
  background: transparent; color: var(--error-text);
  border-color: var(--error-border);
}
.btn-danger:hover            { background: var(--error); color: var(--n-0); border-color: var(--error); }
[data-theme="dark"]
  .btn-danger:hover          { color: var(--n-900); }
.btn:disabled {
  opacity: 0.5; cursor: not-allowed;
  pointer-events: none;
}
.btn-block { width: 100%; }

/* ===== Forms ===== */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field + .field { margin-top: var(--space-4); }
.label {
  font-size: 12px; line-height: 16px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-2);
}
.input, .textarea, .select {
  width: 100%;
  padding: 12px var(--space-3);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 15px;
  line-height: 22px;
  font-family: inherit;
}
.input:focus, .textarea:focus, .select:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--action);
}
.textarea { resize: vertical; min-height: 96px; line-height: 22px; }
.input.pin {
  font-family: 'Inter', monospace;
  font-size: 24px; letter-spacing: 0.8em;
  text-align: center;
  padding-right: calc(var(--space-3) - 0.8em);
}
.field-hint {
  font-size: 13px; line-height: 18px;
  color: var(--text-muted);
}
.field-error {
  font-size: 13px; line-height: 18px; font-weight: 600;
  color: var(--error-text);
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: var(--space-4); }
.card-title {
  font-family: 'Figtree', system-ui, sans-serif;
  font-size: 18px; line-height: 24px; font-weight: 600;
  color: var(--text);
  margin: 0 0 var(--space-3);
}
.card-section + .card-section { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.card > p { margin: 0 0 var(--space-3); }
.card > p:last-child { margin-bottom: 0; }

/* Code-Display / Code-Box / Code-Input */
.code-display {
  font-family: 'Inter', monospace;
  font-size: 32px; line-height: 40px; font-weight: 700;
  letter-spacing: 0.12em;
  text-align: center;
  padding: var(--space-4) var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  user-select: all;
}
.code-box {
  font-family: 'Inter', monospace;
  font-size: 13px; line-height: 18px;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-2);
  word-break: break-all;
  user-select: all;
}
.input.code-input {
  font-family: 'Inter', monospace;
  font-size: 20px; line-height: 28px; font-weight: 600;
  letter-spacing: 0.18em;
  text-align: center;
  text-transform: uppercase;
}

/* Wunsch — Preview + Edit-Modus */
.wish-preview {
  margin: 0 0 var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px; line-height: 22px;
  color: var(--text);
  white-space: pre-wrap;
}
.wish-actions {
  display: flex; justify-content: flex-end; align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* ===== Wichtel-Hero ===== */
.wichtel-hero {
  background: linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-5);
  text-align: center;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.wichtel-hero::before {
  content: "";
  position: absolute;
  top: -40px; right: -40px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, var(--a-100), transparent 70%);
  opacity: 0.6;
  pointer-events: none;
}
[data-theme="dark"] .wichtel-hero::before {
  background: radial-gradient(circle, var(--a-900), transparent 70%);
  opacity: 0.8;
}
.wichtel-hero-overline {
  font-size: 12px; line-height: 16px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  position: relative;
}
.wichtel-hero-name {
  font-family: 'Figtree', system-ui, sans-serif;
  font-size: 40px; line-height: 48px; font-weight: 800;
  color: var(--accent-solid);
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-4);
  position: relative;
}
.wichtel-hero-year {
  display: inline-block;
  font-size: 13px; line-height: 18px; font-weight: 600;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px 10px;
  position: relative;
}
.wichtel-hero-wish {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px dashed var(--border);
  text-align: left;
  position: relative;
}
.wichtel-hero-wish-label {
  font-size: 12px; line-height: 16px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.wichtel-hero-wish-text {
  font-family: 'Figtree', system-ui, sans-serif;
  font-size: 18px; line-height: 26px; font-weight: 600;
  color: var(--text);
  margin: 0;
  white-space: pre-wrap;
}
.wichtel-hero-wish-text.empty {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 500;
}

/* ===== Empty/Info states ===== */
.empty-state {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--text-muted);
}
.empty-state-icon {
  display: inline-flex;
  width: 56px; height: 56px;
  align-items: center; justify-content: center;
  color: var(--p-400);
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  margin-bottom: var(--space-3);
}
.empty-state-title {
  font-family: 'Figtree', system-ui, sans-serif;
  font-size: 18px; line-height: 24px; font-weight: 600;
  color: var(--text);
  margin: 0 0 var(--space-2);
}
.empty-state-text {
  font-size: 14px; line-height: 22px;
  max-width: 360px; margin: 0 auto;
}

/* ===== Member-Liste (Login + Admin) ===== */
.member-list { display: flex; flex-direction: column; gap: 2px; }
.member-item {
  display: flex; align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid transparent;
  min-height: 48px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: var(--text);
  transition: background-color 0.15s, border-color 0.15s;
}
.member-item:hover { background: var(--surface-hover); }
.member-item[aria-pressed="true"],
.member-item.selected {
  border-color: var(--action);
  background: var(--p-50);
}
[data-theme="dark"] .member-item.selected,
[data-theme="dark"] .member-item[aria-pressed="true"] {
  background: var(--surface-2);
  border-color: var(--action);
}
.member-avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-pill);
  background: var(--p-100);
  color: var(--p-700);
  font-weight: 700;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
[data-theme="dark"] .member-avatar {
  background: var(--p-800); color: var(--p-200);
}
.member-avatar.admin {
  background: var(--a-100); color: var(--a-700);
}
[data-theme="dark"] .member-avatar.admin {
  background: var(--a-900); color: var(--a-200);
}
.member-name {
  flex: 1 1 auto;
  font-size: 15px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.member-badge {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  margin-left: var(--space-2);
}

/* ===== History-List ===== */
.history-list {
  display: flex; flex-direction: column;
  gap: var(--space-1);
}
.history-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.history-row .year {
  font-weight: 600; color: var(--text-2);
}
.history-row .who {
  font-weight: 500; color: var(--text);
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: var(--overlay);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
  z-index: 100;
  animation: fadeIn 0.15s;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  max-width: 440px;
  width: 100%;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: pop 0.15s;
}
.modal-title {
  font-family: 'Figtree', system-ui, sans-serif;
  font-size: 21px; line-height: 28px; font-weight: 700;
  color: var(--text);
  margin: 0 0 var(--space-3);
}
.modal-body { color: var(--text-2); font-size: 15px; line-height: 22px; }
.modal-actions {
  display: flex; gap: var(--space-2); justify-content: flex-end;
  margin-top: var(--space-5);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

/* ===== Utility ===== */
.muted { color: var(--text-muted); }
.center { text-align: center; }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.section-title {
  font-family: 'Figtree', system-ui, sans-serif;
  font-size: 18px; line-height: 24px; font-weight: 600;
  color: var(--text);
  margin: var(--space-5) 0 var(--space-3);
}
.section-title:first-child { margin-top: 0; }
.row-between {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--space-3);
}
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-4) 0;
  border: 0;
}

/* ===== Loading ===== */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--action);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.loading-screen {
  min-height: 60vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-3);
  color: var(--text-muted);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Responsive ===== */
@media (max-width: 420px) {
  .app { padding: var(--space-4) var(--space-3) var(--space-8); }
  .wichtel-hero-name { font-size: 32px; line-height: 40px; }
  .wichtel-hero { padding: var(--space-5) var(--space-4); }
}
