:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #f4f5f7);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #17202b);
  --muted: var(--tg-theme-hint-color, #737b87);
  --accent: var(--tg-theme-button-color, #2475d0);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: color-mix(in srgb, var(--muted) 22%, transparent);
  --danger: #c83333;
  --success: #18804a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
#post-fields {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

#post-fields:disabled {
  opacity: 0.65;
}

.app-shell { width: min(100%, 620px); margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom)); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 4px 0 18px; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .12em; margin: 0 0 4px; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 18px; margin: 0; }
.connection-state { color: var(--muted); font-size: 12px; text-align: right; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 12px 0; box-shadow: 0 2px 8px #00000008; }
label { display: block; font-size: 14px; font-weight: 650; margin: 12px 0 7px; }
.panel > label:first-child, form > label:first-child { margin-top: 0; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: var(--bg); }
textarea { resize: vertical; min-height: 92px; }
input[type="file"] { font-size: 13px; padding: 9px; }
.hint, .optional, .footer-note { color: var(--muted); font-size: 12px; line-height: 1.45; }
.hint { margin: 6px 0 0; }
.section-heading { display: flex; justify-content: space-between; align-items: center; }
.icon-button { border: 0; background: transparent; color: var(--accent); font-size: 24px; min-width: 42px; min-height: 42px; border-radius: 10px; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
.queue-list { list-style: none; margin: 12px 0 0; padding: 0; }
.queue-item { border-top: 1px solid var(--line); padding: 12px 0; }
.queue-date { display: block; font-size: 12px; font-weight: 650; color: var(--muted); }
.queue-caption { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.photo-badge { display: inline-block; color: var(--muted); font-size: 11px; margin-top: 7px; }
.primary-button, .secondary-button { min-height: 46px; padding: 11px 16px; border-radius: 11px; border: 0; font-weight: 700; }
.primary-button { background: var(--accent); color: var(--accent-text); margin-top: 12px; }
.secondary-button { background: color-mix(in srgb, var(--accent) 13%, var(--surface)); color: var(--accent); }
.full-width { width: 100%; }
.schedule-fields { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 10px; }
.preview { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 14px; }
.preview-title { font-size: 13px; font-weight: 700; margin: 0 0 6px; }
#preview-caption { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
#preview-photo, #preview-schedule { margin-bottom: 0; }
.form-state { min-height: 1.4em; font-size: 13px; line-height: 1.4; }
[data-kind="error"] { color: var(--danger); }
[data-kind="success"] { color: var(--success); }
.footer-note { text-align: center; margin: 18px 8px 0; }

.access-gate { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px 18px; margin: 12px 0; text-align: center; }
.access-gate h2 { margin: 0 0 8px; }
.access-gate p { color: var(--muted); line-height: 1.5; margin: 0; }

.pagination-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.photo-preview-button { display: block; border: 0; padding: 0; margin-top: 10px; background: transparent; }
.photo-preview { display: block; width: min(100%, 180px); max-height: 180px; object-fit: cover; border-radius: 10px; }
.photo-dialog { width: min(96vw, 900px); max-width: 900px; padding: 12px; border: 0; border-radius: 14px; background: var(--surface); }
.photo-dialog::backdrop { background: #000b; }
.photo-dialog img { display: block; max-width: 100%; max-height: 82vh; object-fit: contain; margin: 28px auto 0; }
.photo-dialog-close { position: absolute; top: 6px; right: 8px; border: 0; background: transparent; color: var(--text); font-size: 28px; line-height: 1; }
