/* Modals, Poster Studio, and iPhone / Mobile Responsive Rules */
.modal { border: 0; border-radius: 24px; padding: 0; background: transparent; max-width: 600px; width: calc(100% - 24px); max-height: calc(100dvh - 32px); margin: auto; }
.modal::backdrop { background: rgba(5, 7, 17, 0.72); backdrop-filter: blur(10px); }
.modal-card { background: var(--surface-solid); color: var(--text); border: 1px solid var(--border); border-radius: 24px; padding: 20px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100dvh - 32px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.close-btn { background: var(--surface-2); border: 0; width: 32px; height: 32px; border-radius: 999px; font-size: 1rem; cursor: pointer; }
.modal-desc, .sync-meta { font-size: 0.84rem; color: var(--muted); }
.poster-style-pills { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.poster-style-pills::-webkit-scrollbar { display: none; }
.poster-style-pill {
  flex-shrink: 0; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
  font-size: 0.76rem; font-weight: 700; cursor: pointer;
}
.poster-style-pill.active { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.ps-dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--border); }
.poster-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.poster-stage { background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; padding: 12px; display: grid; place-items: center; }
#posterPreviewImg { max-width: 100%; max-height: 440px; border-radius: 12px; box-shadow: var(--shadow-3d); object-fit: contain; }
.editor-preview { overflow: hidden; border-radius: 16px; }
.preview-inner { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; }
.preview-left { display: flex; align-items: center; gap: 10px; }
.preview-left div { display: flex; flex-direction: column; font-size: 0.86rem; }
.preview-left span { font-size: 0.74rem; color: var(--muted); font-family: var(--mono); }
.preview-badge { font-family: var(--mono); font-size: 1.25rem; font-weight: 900; }
.form-row { display: grid; gap: 10px; }
.two-col { grid-template-columns: 2fr 1fr; }
.three-col { grid-template-columns: repeat(3, 1fr); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.field input, .field select, .field textarea { color: var(--text); }
.emoji-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.emblem-opt { border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.emblem-opt.active { color: #fff; background: var(--accent); border-color: transparent; }
.form-checks { display: flex; gap: 14px; flex-wrap: wrap; }
.check-pill { display: inline-flex; gap: 6px; align-items: center; font-size: 0.84rem; cursor: pointer; }
.theme-swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.theme-swatch { display: flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; padding: 8px 9px; font-size: 0.76rem; font-weight: 700; cursor: pointer; }
.theme-swatch.active { border-color: var(--accent); background: var(--surface); }
.swatch-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.sync-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.sync-qr-box { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); flex-wrap: wrap; }
#syncQrMount svg { border-radius: 10px; display: block; }
.sync-qr-info { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 180px; font-size: 0.8rem; }
.sync-qr-info span { color: var(--muted); }
.sync-btn-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.file-label { cursor: pointer; }
.divider { border: 0; border-top: 1px solid var(--border); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding-bottom: env(safe-area-inset-bottom); }
.mobile-fab { display: none; }
.toast { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 0.85rem; font-weight: 700; opacity: 0; pointer-events: none; transition: all 0.2s ease; z-index: 60; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 820px) { .hero-grid { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .container, .topbar-inner { padding-left: 12px; padding-right: 12px; }
  .brand { gap: 8px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
  .brand-title { font-size: 0.86rem; white-space: nowrap; letter-spacing: 0.04em; }
  .brand-sub, #newDdayBtn { display: none; }
  .topbar-actions { gap: 4px; }
  .pill-btn { padding: 6px 8px; font-size: 0.74rem; min-height: 34px; white-space: nowrap; }
  #syncStatusBtn { padding: 6px 9px; font-size: 0.72rem; }
  #notifyBtn span { display: none; }
  .hero-stage { padding: 20px 16px; }
  .hero-clock { grid-template-columns: repeat(4, 1fr); gap: 7px; }
  .clock-cell span { font-size: 1.35rem; }
  .two-col, .three-col { grid-template-columns: 1fr; }
  .theme-swatches { grid-template-columns: repeat(2, 1fr); }
  .field input, .field select, .field textarea, .search-input, .sort-select, .sync-row input { font-size: 16px; min-height: 44px; }
  .icon-btn { width: 40px; height: 40px; }
  .modal { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 24px 24px 0 0; }
  .modal-card { border-radius: 24px 24px 0 0; max-height: 90dvh; }
  .mobile-fab {
    display: inline-flex; align-items: center; gap: 8px; position: fixed; right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 40; border: 0; border-radius: 999px;
    padding: 13px 20px; font-size: 0.92rem; font-weight: 800; color: #fff; cursor: pointer;
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    box-shadow: inset 0 1px 1px rgba(255,255,255,0.45), 0 12px 28px rgba(79, 70, 229, 0.55);
  }
}
