:root {
  --bg: #0f1219;
  --surface: #181d28;
  --surface-2: #222938;
  --border: rgba(255, 255, 255, 0.09);
  --text: #f3f5f9;
  --text-muted: #98a2b3;
  --accent: #ff8c24;
  --accent-strong: #ff7700;
  --primary: #3b82f6;
  --primary-strong: #2563eb;
  --danger: #ff453a;
  --success: #30d158;
  --radius: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(15, 18, 25, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

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

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

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

.btn-icon-pill {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.main-content {
  padding: 14px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.picker-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hint-text {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.dir-banner {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(48, 209, 88, 0.12);
  border: 1px solid rgba(48, 209, 88, 0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.08s ease, opacity 0.15s ease, background 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-lg {
  min-height: 48px;
  padding: 12px 18px;
  width: 100%;
}

.btn-block {
  min-height: 50px;
  width: 100%;
  padding: 12px 20px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

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

.btn-accent {
  background: var(--accent);
  color: #16130f;
}

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

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  min-height: 44px;
  padding: 10px 14px;
}

.btn-chip {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 11px;
  font-size: 13px;
  font-weight: 600;
}

.btn-danger-soft {
  color: #ff7b72;
  background: rgba(255, 69, 58, 0.12);
  border-color: rgba(255, 69, 58, 0.25);
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  padding: 4px;
  cursor: pointer;
}

.link-btn.danger {
  color: var(--danger);
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.meta-line {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  word-break: break-word;
}

.header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.preview-stage {
  position: relative;
  width: 100%;
  background: #090b10;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  max-height: 54vh;
}

#previewCanvas {
  max-width: 100%;
  max-height: 54vh;
  width: auto;
  height: auto;
  display: block;
}

.preview-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(15, 18, 25, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 12px;
  color: var(--text);
  pointer-events: none;
}

.per-photo-bar {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.per-photo-date-info {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.label-muted {
  color: var(--text-muted);
}

.per-photo-actions {
  display: flex;
  gap: 6px;
}

.single-date-editor {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.inline-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.thumb-strip {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.thumb-item {
  position: relative;
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  background: #0b0d12;
  cursor: pointer;
  padding: 0;
}

.thumb-item.active {
  border-color: var(--accent);
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-tag {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 10px;
  padding: 2px 3px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.setting-group:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  background: #11151f;
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.segmented-3 {
  grid-template-columns: repeat(3, 1fr);
}

.seg-btn {
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.seg-btn.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

/* 16px prevents automatic zoom on iOS Safari focus */
.input-control {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #11151f;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
}

.suffix-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mode-explain {
  margin: 0;
  font-size: 13px;
  color: #cbd5e1;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 10px;
  padding: 9px 11px;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  padding: 0;
}

.color-swatch.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(255, 140, 36, 0.45);
}

.color-picker-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
}

.color-picker-wrap input[type="color"] {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

.slider-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.range-input {
  width: 100%;
  accent-color: var(--accent);
  height: 28px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: end;
}

.toggle-row {
  align-items: center;
}

.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 32px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-toggle {
  position: absolute;
  inset: 0;
  background: #333b4d;
  border-radius: 999px;
  transition: 0.2s;
  cursor: pointer;
}

.slider-toggle::before {
  content: "";
  position: absolute;
  height: 26px;
  width: 26px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #ffffff;
  transition: 0.2s;
}

.switch input:checked + .slider-toggle {
  background: var(--success);
}

.switch input:checked + .slider-toggle::before {
  transform: translateX(20px);
}

.result-card {
  border-color: rgba(255, 140, 36, 0.45);
  background: linear-gradient(180deg, rgba(255, 140, 36, 0.08), var(--surface));
}

.result-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.notice-box {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(255, 209, 59, 0.12);
  border: 1px solid rgba(255, 209, 59, 0.35);
  color: #fde68a;
  font-size: 13px;
}

.result-actions {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.secondary-save-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(15, 18, 25, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}

.progress-wrap {
  margin-bottom: 10px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin-bottom: 6px;
}

.progress-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s ease;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.68);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}

.modal-sheet {
  width: 100%;
  max-width: 640px;
  max-height: 85dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.modal-header h2 {
  margin: 0;
  font-size: 17px;
}

.guide-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
}

.guide-list ul {
  margin: 6px 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.guide-list code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 13px;
}
