:root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --surface-2:      #ffffff;
  --page-plane:     #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --border:         rgba(11,11,11,0.10);

  --accent:         #2a78d6;
  --accent-bg:      #e8f0fb;
  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-warning-bg: #fff6e0;
  --status-critical: #d03b3b;
  --status-critical-bg: #fdeaea;

  --radius: 14px;
  --radius-sm: 9px;
  font-size: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --surface-2:      #222221;
    --page-plane:     #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --border:         rgba(255,255,255,0.10);

    --accent:         #3987e5;
    --accent-bg:      #16283e;
    --status-warning-bg: #3a2f0d;
    --status-critical-bg: #3a1616;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  padding-bottom: 40px;
}

/* ---------- Header ---------- */
header.app-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
}
header.app-header h1 {
  font-size: 1rem; margin: 0; font-weight: 700; line-height: 1.2;
}
.chrono-line {
  font-size: 0.85rem; color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.chrono-line .value { font-weight: 700; color: var(--text-primary); }
.tabular { font-variant-numeric: tabular-nums; }

.header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn, button {
  font: inherit; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-primary);
  padding: 8px 13px; cursor: pointer; font-weight: 600; font-size: 0.82rem;
  text-decoration: none; display: inline-flex; align-items: center; gap: 4px;
}
.btn.primary, button.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.ghost, button.ghost { background: transparent; }
.btn.crew, button.crew {
  margin-left: auto; padding: 6px 10px; font-size: 0.72rem; opacity: 0.75;
}
button:active, .btn:active { transform: scale(0.97); }

main { max-width: 640px; margin: 0 auto; padding: 12px 12px 0; }

.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}
.card h2 { font-size: 0.95rem; margin: 0 0 8px; }
label { display: block; font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=file], textarea {
  font: inherit; width: 100%; padding: 9px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-primary);
  margin-bottom: 10px;
}
textarea { resize: vertical; min-height: 60px; }
.hint-text { font-size: 0.72rem; color: var(--text-muted); margin: 6px 0 0; }
.btn-row { display: flex; gap: 10px; align-items: center; }
.post-status { font-size: 0.78rem; color: var(--text-muted); }
.login-error { color: var(--status-critical); font-size: 0.8rem; }

#imagePreviewWrap { position: relative; display: inline-block; margin-bottom: 10px; }
#imagePreviewWrap img { max-width: 160px; max-height: 160px; border-radius: var(--radius-sm); display: block; }
#imagePreviewWrap .del-btn {
  position: absolute; top: -8px; right: -8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 50%; width: 28px; height: 28px;
  padding: 0; font-size: 0.9rem;
}

/* ---------- Feed ---------- */
.post-card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 14px; overflow: hidden;
}
.post-media {
  width: 100%; aspect-ratio: 4 / 3; background: var(--gridline);
  overflow: hidden;
}
.post-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-body { padding: 12px 14px; }
.post-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.post-author { font-size: 0.85rem; font-weight: 700; }
.post-time { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }
.post-text { margin: 0 0 4px; font-size: 0.95rem; line-height: 1.4; white-space: pre-wrap; }
.post-caption { margin: 0; font-size: 0.78rem; color: var(--text-secondary); }
.post-card .del-btn {
  background: none; border: none; color: var(--status-critical); font-size: 0.95rem;
  padding: 2px 4px; margin-top: 6px;
}
.empty-hint { text-align: center; color: var(--text-muted); font-size: 0.85rem; padding: 30px 14px; }

/* ---------- Modal sheet ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.overlay[hidden] { display: none; }
.sheet {
  background: var(--surface-1); width: 100%; max-width: 480px; border-radius: 18px 18px 0 0;
  padding: 18px; max-height: 85vh; overflow-y: auto;
}
.sheet h3 { margin-top: 0; }
.sheet .sheet-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

footer.hint {
  max-width: 640px; margin: 0 auto;
  text-align: center; color: var(--text-muted); font-size: 0.72rem; padding: 18px 14px 30px;
}
