:root {
  --bg: #FAF5EE;
  --bg-soft: #F3ECE2;
  --surface: #FFFFFF;
  --surface-hover: #FFFDFB;
  --border: #E8DDD0;
  --border-strong: #D6C7B6;

  --ink: #262120;         /* 小埋 黑緬因炭墨色 */
  --ink-secondary: #6E5F56; /* 小點 暹羅重點色 */
  --ink-muted: #9B8B80;

  --accent: #DC6B4A;      /* 暖陶橘 */
  --accent-hover: #C45738;
  --accent-soft: #FCECE6;

  --unused-bg: #E7F5EC;
  --unused-fg: #1F7A44;
  --scheduled-bg: #FEF3D6;
  --scheduled-fg: #A86407;
  --posted-bg: #EFEBF6;
  --posted-fg: #5B4982;
  --danger: #C94038;
  --danger-soft: #FDECEB;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-full: 999px;

  --shadow-sm: 0 2px 8px rgba(38, 33, 32, 0.05);
  --shadow-md: 0 8px 24px rgba(38, 33, 32, 0.08);
  --shadow-lg: 0 18px 42px rgba(38, 33, 32, 0.14);

  --sidebar-w: 248px;
  --bottom-nav-h: 68px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  transition: transform 0.14s ease, background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

img {
  max-width: 100%;
  display: block;
}

/* ---------------- App Shell ---------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Desktop Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.brand-sub {
  font-size: 12px;
  color: var(--ink-muted);
}

.sidebar-day-card {
  background: linear-gradient(135deg, #262120 0%, #3E3330 100%);
  color: #FFFBF6;
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.sidebar-day-label {
  font-size: 12px;
  opacity: 0.78;
}

.sidebar-day-value {
  font-size: 22px;
  font-weight: 800;
  margin-top: 2px;
  letter-spacing: 0.01em;
}

.sidebar-day-sub {
  margin-top: 8px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #F6D8C8;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-secondary);
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-soft);
  color: var(--ink);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.nav-item .nav-icon {
  font-size: 19px;
  width: 24px;
  text-align: center;
}

.nav-badge {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-soft);
  color: var(--ink-secondary);
}

.nav-item.active .nav-badge {
  background: var(--accent);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-muted);
}

.sidebar-footer a {
  color: var(--accent-hover);
  text-decoration: none;
  font-weight: 600;
}

/* Mobile Header */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 25;
  background: rgba(250, 245, 238, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-brand img {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.mobile-brand-name {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}

.mobile-day-pill {
  font-size: 12px;
  font-weight: 700;
  background: var(--ink);
  color: #FFFBF6;
  padding: 5px 11px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 28px 32px 48px;
  max-width: 1320px;
}

/* Mobile Bottom Nav */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  z-index: 30;
  grid-template-columns: repeat(4, 1fr);
}

.bottom-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 4px;
}

.bottom-nav-btn .b-icon {
  font-size: 20px;
  line-height: 1;
}

.bottom-nav-btn.active {
  color: var(--accent-hover);
}

/* ---------------- Reusable Components ---------------- */
.view-section {
  display: none;
  animation: fadeIn 0.22s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}

.page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-desc {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--ink-secondary);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  max-width: 100%;
}

.card-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 13px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(220, 107, 74, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-dark {
  background: var(--ink);
  color: #FFFBF6;
}

.btn-dark:hover:not(:disabled) {
  background: #3D3533;
}

.btn-secondary {
  background: var(--bg-soft);
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: #EAE0D5;
}

.btn-outline {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-hover);
}

.btn-success {
  background: #23884D;
  color: #fff;
  box-shadow: 0 4px 12px rgba(35, 136, 77, 0.25);
}

.btn-success:hover:not(:disabled) {
  background: #1C703F;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 4px 12px rgba(201, 64, 56, 0.28);
}

.btn-danger:hover:not(:disabled) {
  background: #AE322B;
}

.btn-danger-ghost {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-danger-ghost:hover:not(:disabled) {
  background: #FAD7D5;
}

.btn-sm {
  padding: 8px 13px;
  font-size: 13px;
  border-radius: 10px;
}

.btn-lg {
  padding: 14px 22px;
  font-size: 15px;
  border-radius: 15px;
}

.btn-block {
  width: 100%;
}

/* Pills & Badges */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  padding: 7px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  background: var(--bg-soft);
  color: var(--ink-secondary);
  border: 1px solid transparent;
}

.pill:hover {
  background: #EAE0D5;
  color: var(--ink);
}

.pill.active {
  background: var(--ink);
  color: #FFFBF6;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
}

.badge-unused { background: var(--unused-bg); color: var(--unused-fg); }
.badge-scheduled { background: var(--scheduled-bg); color: var(--scheduled-fg); }
.badge-posted { background: var(--posted-bg); color: var(--posted-fg); }
.badge-xiaomai { background: #262120; color: #FFF8F0; }
.badge-xiaodian { background: #F5ECE3; color: #6B4D3B; border: 1px solid #DECBB8; }
.badge-both { background: var(--accent-soft); color: var(--accent-hover); }
.badge-unknown { background: #EFECE9; color: var(--ink-muted); }

/* ---------------- Stats Strip ---------------- */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 600;
}

.stat-num {
  font-size: 24px;
  font-weight: 800;
  margin-top: 2px;
  line-height: 1.2;
}

.stat-num.accent { color: var(--accent-hover); }
.stat-num.green { color: var(--unused-fg); }

/* ---------------- Today Studio ---------------- */
.draw-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 20px;
  align-items: start;
}

.photo-stage {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #1C1918;
  aspect-ratio: 4 / 5;
  max-height: 520px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.photo-stage.shuffling img {
  animation: shufflePulse 0.35s ease;
}

@keyframes shufflePulse {
  0% { opacity: 0.4; transform: scale(0.96); }
  100% { opacity: 1; transform: scale(1); }
}

.photo-stage-badges {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

/* Carousel Controls & Strip */
.carousel-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(24, 20, 19, 0.72);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
}

.carousel-nav-btn:hover {
  background: rgba(24, 20, 19, 0.92);
}

.carousel-nav-btn.prev { left: 10px; }
.carousel-nav-btn.next { right: 10px; }

.carousel-counter {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(24, 20, 19, 0.78);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  z-index: 4;
  pointer-events: none;
}

.carousel-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 2px 4px;
  align-items: center;
  min-width: 0;
  max-width: 100%;
}

.carousel-thumb {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 12px;
  overflow: hidden;
  border: 2.5px solid transparent;
  flex-shrink: 0;
  cursor: pointer;
  background: #221E1D;
}

.carousel-thumb.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(220, 107, 74, 0.25);
}

.carousel-thumb img,
.carousel-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.carousel-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(24, 20, 19, 0.82);
  color: #fff;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.carousel-thumb-vid {
  position: absolute;
  bottom: 2px;
  left: 2px;
  font-size: 10px;
  background: rgba(24, 20, 19, 0.8);
  color: #fff;
  border-radius: 4px;
  padding: 0 3px;
}

.carousel-add-btn {
  width: 62px;
  height: 62px;
  border-radius: 12px;
  border: 2px dashed var(--border-strong);
  background: var(--bg);
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.carousel-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
  background: var(--accent-soft);
}

/* Story Time-Cluster Cards */
.cluster-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.story-clusters-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.story-cluster-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.story-cluster-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.story-cluster-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.story-cluster-meta {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.story-cluster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 10px;
}

.story-mini-card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: #221E1D;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.story-mini-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.story-mini-card.is-posted img,
.story-mini-card.is-posted video {
  filter: saturate(0.72) brightness(0.88);
}

.story-mini-card img,
.story-mini-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-mini-top {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  display: flex;
  justify-content: space-between;
  gap: 4px;
}

.story-mini-time {
  position: absolute;
  bottom: 6px;
  left: 6px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(24, 20, 19, 0.78);
  color: #fff;
  padding: 2px 6px;
  border-radius: 6px;
}

@media (max-width: 960px) {
  .story-cluster-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
}

/* IG Visual Match Results */
.ig-match-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  margin-top: 12px;
}

.ig-match-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.ig-match-thumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ig-match-thumbs img {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  background: #221E1D;
}

.ig-match-info {
  flex: 1;
  min-width: 0;
  font-size: 13px;
}

.story-mini-card.selected {
  border: 2.5px solid var(--accent);
  box-shadow: 0 0 0 2px rgba(220, 107, 74, 0.25);
}

.story-mini-card .select-order-badge,
.story-mini-card .select-circle-empty {
  bottom: 6px;
  right: 6px;
  left: auto;
  min-width: 24px;
  width: 24px;
  height: 24px;
  font-size: 11px;
}

/* Delete Confirmation Modal */
.delete-preview-strip {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.delete-preview-thumb {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  overflow: hidden;
  background: #221E1D;
  border: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
}

.delete-preview-thumb img,
.delete-preview-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.delete-preview-more {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px dashed var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-secondary);
}

.delete-option-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.delete-option-card.cloud {
  background: #FFF9F5;
  border-color: #EBC8BA;
}

.delete-check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.delete-check-row input[type="checkbox"] {
  margin-top: 2px;
  width: 18px;
  height: 18px;
  accent-color: var(--danger);
  flex-shrink: 0;
}

.delete-radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-strong);
}

.delete-radio-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
}

.delete-radio-item:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.delete-radio-item.danger:has(input:checked) {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.delete-radio-item input[type="radio"] {
  margin-top: 2px;
  accent-color: var(--danger);
  flex-shrink: 0;
}

.delete-cloud-notice {
  margin-top: 10px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-muted);
}

.delete-progress-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 13px;
  font-weight: 700;
}

/* IG Share Helper Modal */
.ig-share-file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.ig-share-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.ig-share-row img,
.ig-share-row video {
  width: 48px;
  height: 48px;
  border-radius: 9px;
  object-fit: cover;
  background: #221E1D;
  flex-shrink: 0;
}

.ig-share-row-info {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
}

.ig-share-row-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Gallery Multi-Select */
.photo-card.selected {
  border: 2.5px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(220, 107, 74, 0.2);
}

.select-order-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  min-width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: var(--shadow-sm);
}

.select-circle-empty {
  position: absolute;
  bottom: 8px;
  left: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(24, 20, 19, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.9);
}

.multi-select-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 22px;
  z-index: 50;
  background: var(--ink);
  color: #FFFBF6;
  padding: 12px 16px;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  display: none;
  align-items: center;
  gap: 12px;
  max-width: min(560px, calc(100vw - 24px));
  width: max-content;
}

.multi-select-bar.open {
  display: flex;
}

@media (max-width: 960px) {
  .multi-select-bar {
    bottom: calc(var(--bottom-nav-h) + 12px + env(safe-area-inset-bottom, 0px));
    width: calc(100vw - 24px);
    justify-content: space-between;
  }
}

.photo-meta-bar {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-scene-box {
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--ink-secondary);
}

/* Form Controls */
.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}

.input, .textarea, .select {
  width: 100%;
  padding: 10px 13px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: #FFFDFB;
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(220, 107, 74, 0.15);
}

.textarea {
  resize: vertical;
  min-height: 122px;
  line-height: 1.65;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-soft);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  cursor: pointer;
  user-select: none;
}

.toggle-chip input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

/* AI Caption Candidates */
.candidates-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0;
}

.candidate-card {
  border: 1.5px solid var(--border);
  background: var(--bg);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease, transform 0.12s ease;
}

.candidate-card:hover {
  border-color: var(--accent);
  background: #FFFBF7;
}

.candidate-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.candidate-style {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent-hover);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
}

.candidate-text {
  font-size: 14px;
  white-space: pre-wrap;
  color: var(--ink);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.action-grid .span-2 {
  grid-column: span 2;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 44px 20px;
  color: var(--ink-secondary);
}

.empty-emoji {
  font-size: 48px;
  margin-bottom: 10px;
}

.empty-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 14px;
  max-width: 440px;
  margin: 0 auto 20px;
}

/* ---------------- Gallery & Upload ---------------- */
.import-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.import-tab {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-secondary);
}

.import-tab.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 26px 18px;
  text-align: center;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone-icon {
  font-size: 32px;
  margin-bottom: 6px;
}

.dropzone-title {
  font-size: 15px;
  font-weight: 800;
}

.dropzone-sub {
  font-size: 13px;
  color: var(--ink-muted);
  margin-top: 4px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 16px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 14px;
}

.photo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  display: flex;
  flex-direction: column;
}

.photo-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.photo-card.is-posted .photo-thumb img {
  filter: saturate(0.75) brightness(0.92);
}

.photo-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #221E1D;
  overflow: hidden;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumb-top {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  gap: 4px;
}

.photo-card-body {
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.photo-card-caption {
  font-size: 12px;
  color: var(--ink-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 34px;
}

.photo-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-muted);
}

/* ---------------- Calendar ---------------- */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.cal-month-title {
  font-size: 18px;
  font-weight: 800;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-weekday {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
  padding: 6px 0;
}

.cal-cell {
  min-height: 86px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.cal-cell.empty {
  background: transparent;
  border-color: transparent;
}

.cal-cell.today {
  border-color: var(--accent);
  background: #FFF8F4;
}

.cal-day-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-secondary);
}

.cal-cell.today .cal-day-num {
  color: var(--accent-hover);
}

.cal-thumb-wrap {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  cursor: pointer;
}

.cal-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cal-day-tag {
  position: absolute;
  bottom: 2px;
  left: 2px;
  right: 2px;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  border-radius: 5px;
  padding: 1px 3px;
  background: rgba(38, 33, 32, 0.8);
  color: #fff;
}

.cal-day-tag.scheduled {
  background: rgba(168, 100, 7, 0.9);
}

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.timeline-item {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}

.timeline-item:hover {
  border-color: var(--accent);
}

.timeline-item img {
  width: 66px;
  height: 66px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
}

.timeline-info {
  flex: 1;
  min-width: 0;
}

.timeline-caption {
  font-size: 13px;
  color: var(--ink-secondary);
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 4px;
}

/* ---------------- Settings & Mobile Connect ---------------- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.lan-box {
  display: flex;
  gap: 16px;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.qr-box {
  width: 116px;
  height: 116px;
  background: #fff;
  border-radius: 12px;
  padding: 8px;
  border: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.guide-details {
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--ink-secondary);
}

.guide-details summary {
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}

.guide-details ol {
  margin: 10px 0 4px;
  padding-left: 20px;
}

.guide-details li {
  margin-bottom: 6px;
}

.code-inline {
  background: #EAE0D5;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  color: var(--ink);
  word-break: break-all;
}

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 20, 19, 0.56);
  backdrop-filter: blur(4px);
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
  box-shadow: var(--shadow-lg);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-soft);
  font-size: 18px;
}

/* ---------------- Toast ---------------- */
.toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  background: var(--ink);
  color: #FFFBF6;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.2s ease;
}

.toast.success { background: #1F7A44; }
.toast.error { background: var(--danger); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------------- Responsive (Mobile First Feel) ---------------- */
@media (max-width: 960px) {
  .sidebar {
    display: none;
  }

  .mobile-header {
    display: flex;
  }

  .bottom-nav {
    display: grid;
  }

  .main-content {
    margin-left: 0;
    padding: 16px 14px calc(var(--bottom-nav-h) + 28px + env(safe-area-inset-bottom, 0px));
  }

  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .studio-grid,
  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .studio-grid > *,
  .settings-grid > * {
    min-width: 0;
    max-width: 100%;
  }

  .photo-stage {
    max-height: 410px;
  }

  .photo-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .cal-cell {
    min-height: 68px;
    padding: 4px;
  }

  .lan-box {
    flex-direction: column;
    text-align: center;
  }
}
