:root {
  --bg: #fdfbff;
  --bg-gradient: linear-gradient(180deg, #e7dbff 0%, #d0eaff 45%, #fdfbff 85%);
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-elevated: #f4f1ff;
  --text: #1a1a2e;
  --text-secondary: #4a4a60;
  --text-muted: #888899;
  --accent: #7c3aed;
  --border: rgba(120,90,200,0.12);
  --border-strong: rgba(120,90,200,0.24);
  --shadow-sm: 0 2px 8px rgba(120,90,200,0.06);
  --shadow-md: 0 6px 18px rgba(120,90,200,0.1);
  --shadow-lg: 0 10px 30px rgba(120,90,200,0.18);
  --red: linear-gradient(135deg, #ff4571 0%, #e81e63 100%);
  --purple: linear-gradient(135deg, #a855f7 0%, #8b5cf6 100%);
  --orange: linear-gradient(135deg, #ff9f43 0%, #ff6b35 100%);
  --sa-top: env(safe-area-inset-top, 0);
  --sa-bot: env(safe-area-inset-bottom, 0);
  --sa-left: env(safe-area-inset-left, 0);
  --sa-right: env(safe-area-inset-right, 0);
  --radius: 18px;
  --radius-lg: 26px;
  --footer-h: 96px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin: 0; padding: 0; }
html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro', 'Hiragino Sans', sans-serif;
  background: var(--bg); color: var(--text);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}
body {
  min-height: 100vh; min-height: 100dvh;
  width: 100%;
  overflow-x: hidden;
  background: var(--bg-gradient) no-repeat;
  background-attachment: fixed;
  padding: calc(var(--sa-top) + 16px) calc(20px + var(--sa-right)) calc(var(--footer-h) + var(--sa-bot) + 20px) calc(20px + var(--sa-left));
}
.hidden { display: none !important; }

/* 上部 avatar / pill */
.top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: #fff; color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; box-shadow: var(--shadow-sm);
}
.pending-pill {
  background: #fff; color: var(--accent);
  font-weight: 700; font-size: 16px;
  padding: 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow-sm);
  display: inline-flex; align-items: center; gap: 6px;
  min-width: 52px; justify-content: center;
}
.pending-pill::before { content: '📂'; font-size: 16px; }

.page-title {
  font-size: 36px; font-weight: 800;
  letter-spacing: -1px; line-height: 1.15;
  color: var(--text); margin: 4px 0 24px;
}

/* 記事選択バー */
.article-bar {
  position: relative; background: #fff; border-radius: 999px;
  display: flex; align-items: center;
  padding: 6px 8px 6px 22px;
  box-shadow: var(--shadow-md); margin-bottom: 14px;
}
.article-bar-icon { font-size: 22px; margin-right: 12px; }
.article-bar-select {
  flex: 1; border: none; background: transparent; color: var(--text);
  font-size: 17px; font-family: inherit; font-weight: 500;
  padding: 16px 8px 16px 0;
  appearance: none; -webkit-appearance: none; outline: none;
}
.article-bar-arrow { color: var(--text-muted); font-size: 20px; padding-right: 20px; pointer-events: none; }

.new-article-details { margin-bottom: 20px; }
.new-article-details summary {
  list-style: none; cursor: pointer;
  color: var(--accent); font-size: 15px; font-weight: 600;
  padding: 12px 8px; user-select: none; text-align: center;
}
.new-article-details summary::-webkit-details-marker { display: none; }
.new-article-form {
  display: flex; flex-direction: column; gap: 10px;
  background: #fff; border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm);
}
.text-field {
  width: 100%; padding: 16px;
  background: var(--bg-elevated); color: var(--text);
  border: none; border-radius: 14px;
  font-size: 17px; font-family: inherit; outline: none;
}

/* モードタブ */
.mode-tabs {
  display: flex; gap: 6px; background: #fff;
  border-radius: 14px; padding: 5px;
  box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.mode-tab {
  flex: 1; padding: 12px 10px; border: none; background: transparent;
  color: var(--text-muted); font-size: 15px; font-weight: 700;
  border-radius: 10px; cursor: pointer; font-family: inherit;
}
.mode-tab.active { background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%); color: #fff; }

/* ライブカメラ */
.live-camera {
  position: relative;
  background: #000; border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 3 / 4;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
}
.live-camera.hidden { display: none; }
.live-camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-overlay {
  position: absolute; top: 12px; right: 12px;
  display: flex; gap: 8px;
}
.flip-btn {
  background: rgba(0,0,0,0.5); color: #fff;
  border: none; width: 40px; height: 40px; border-radius: 50%;
  cursor: pointer; font-size: 18px;
  backdrop-filter: blur(8px);
}
.camera-controls {
  position: absolute; bottom: 16px; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-around;
  padding: 0 16px;
}
.kind-btn {
  background: rgba(0,0,0,0.5); color: #fff;
  border: none; padding: 8px 16px; border-radius: 999px;
  cursor: pointer; font-size: 14px; font-weight: 600;
  backdrop-filter: blur(8px);
}
.kind-btn.active { background: #fff; color: #000; }
.shutter-btn {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(255,255,255,0.3);
  border: 3px solid #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.1s;
}
.shutter-btn:active { transform: scale(0.95); }
.shutter-btn .shutter-ring {
  width: 56px; height: 56px; border-radius: 50%;
  background: #fff;
  transition: all 0.2s;
}
.shutter-btn.recording .shutter-ring {
  width: 28px; height: 28px; border-radius: 6px;
  background: #ef4444;
}
.record-time {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(239,68,68,0.9); color: #fff;
  padding: 4px 12px; border-radius: 999px;
  font-family: 'SF Mono', monospace; font-size: 14px; font-weight: 700;
  display: none;
}
.record-time.active { display: block; }

/* ピッカー（3つの丸） */
.picker-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 22px 10px; margin-bottom: 20px;
}
.picker-grid.hidden { display: none; }
.circle-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; cursor: pointer; user-select: none;
  transition: transform 0.15s;
}
.circle-item:active { transform: scale(0.94); }
.circle {
  width: 90px; height: 90px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
}
.circle-red { background: var(--red); }
.circle-purple { background: var(--purple); }
.circle-orange { background: var(--orange); }
.circle-icon { font-size: 44px; line-height: 1; filter: drop-shadow(0 3px 4px rgba(0,0,0,0.25)); }
.circle-label { font-size: 14px; font-weight: 700; color: var(--text); text-align: center; }

/* 一時保存 */
.queue-section {
  background: #fff; border-radius: var(--radius-lg);
  padding: 22px 20px 20px; box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.section-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }
.section-header h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.queue-count { font-size: 15px; color: var(--text-muted); font-weight: 600; }
.queue-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.queue-item {
  position: relative; aspect-ratio: 1;
  background: var(--bg-elevated); border-radius: 14px; overflow: hidden;
  box-shadow: 0 2px 6px rgba(120,90,200,0.08);
}
.queue-item img, .queue-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.queue-item .type-badge {
  position: absolute; top: 6px; left: 6px;
  background: rgba(0,0,0,0.7); color: #fff;
  font-size: 11px; padding: 2px 7px; border-radius: 6px;
  font-weight: 700;
}
.queue-item .delete-btn {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,0.65); color: #fff; border: none;
  width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.queue-item .delete-btn:active { background: #ef4444; }
.queue-item .status-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.8); color: #fff;
  font-size: 11px; text-align: center; padding: 4px; font-weight: 600;
}
.queue-empty {
  text-align: center; padding: 32px 12px;
  font-size: 14px; color: var(--text-muted); line-height: 1.5;
}

.status-line {
  text-align: center; min-height: 20px;
  font-size: 13px; color: var(--text-muted);
  padding: 6px 0 10px;
}

.bottom-spacer { height: 16px; }

/* 底部固定バー */
.action-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  padding: 14px 20px calc(14px + var(--sa-bot));
  padding-left: calc(20px + var(--sa-left));
  padding-right: calc(20px + var(--sa-right));
  background: rgba(253,251,255,0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--border);
  display: flex; gap: 12px; align-items: stretch;
}
.btn-primary {
  flex: 1; min-height: 64px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 0 26px;
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  color: #fff; border: none; border-radius: 20px;
  font-size: 19px; font-weight: 800; cursor: pointer; font-family: inherit;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 8px 20px rgba(124,58,237,0.4);
  letter-spacing: -0.3px;
}
.btn-primary:active:not(:disabled) { transform: scale(0.98); box-shadow: 0 5px 12px rgba(124,58,237,0.35); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; }
.btn-primary-icon { font-size: 22px; }
.btn-primary-sub { font-size: 13px; font-weight: 600; opacity: 0.9; }
.btn-primary-sub:empty { display: none; }
.btn-ghost {
  min-width: 96px; min-height: 64px; padding: 0 20px;
  background: #fff; color: #ef4444;
  border: 1px solid var(--border); border-radius: 20px;
  font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.btn-ghost:active:not(:disabled) { background: #fef2f2; }
.btn-ghost:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-secondary {
  min-height: 52px; padding: 0 18px;
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  color: #fff; border: none; border-radius: 14px;
  font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.btn-secondary:active { opacity: 0.85; }

.toast {
  position: fixed;
  bottom: calc(var(--footer-h) + var(--sa-bot) + 18px);
  left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 24px);
  background: #1a1a2e; color: #fff;
  padding: 12px 22px; border-radius: 999px;
  font-size: 14px; font-weight: 500; z-index: 100;
  box-shadow: 0 8px 28px rgba(0,0,0,0.25);
  animation: slideUp 0.25s ease;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toast.hidden { display: none; }
.toast.success { background: #10b981; }
.toast.error { background: #ef4444; }
@keyframes slideUp {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

input, select, textarea { font-size: 16px; }

@media (min-width: 640px) {
  body { padding-left: calc(max(20px, 50vw - 240px) + var(--sa-left)); padding-right: calc(max(20px, 50vw - 240px) + var(--sa-right)); }
  .action-bar { padding-left: calc(max(20px, 50vw - 240px) + var(--sa-left)); padding-right: calc(max(20px, 50vw - 240px) + var(--sa-right)); }
}
