:root {
  --bg-deep: #0b0f19;
  --bg-navy: #111827;
  --bg-card: #161f33;
  --bg-card-elevated: #1e2942;
  --bg-input: #0d1322;
  --border-subtle: rgba(148, 163, 184, 0.16);
  --border-pink: rgba(255, 42, 122, 0.45);
  --pink-primary: #ff2a7a;
  --pink-secondary: #ff5e62;
  --pink-grad: linear-gradient(135deg, #ff2a7a 0%, #ff5e62 100%);
  --navy-grad: linear-gradient(180deg, #121a2d 0%, #0b0f19 100%);
  --text-main: #f8fafc;
  --text-sub: #cbd5e1;
  --text-muted: #94a3b8;
  --accent-cyan: #38bdf8;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --radius-card: 18px;
  --radius-sm: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-deep);
  background-image: radial-gradient(circle at 85% 5%, rgba(255, 42, 122, 0.14), transparent 40%),
    radial-gradient(circle at 10% 30%, rgba(56, 189, 248, 0.08), transparent 45%);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

body {
  padding-top: calc(64px + var(--safe-top));
  padding-bottom: calc(82px + var(--safe-bottom));
}

.hidden {
  display: none !important;
}

/* Header */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding-top: var(--safe-top);
  background: rgba(11, 15, 25, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-pink);
}

.header-inner {
  max-width: 680px;
  margin: 0 auto;
  height: 62px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--pink-grad);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 14px rgba(255, 42, 122, 0.4);
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.header-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}

.status-pill.online {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.45);
}

.status-pill.offline {
  background: rgba(239, 68, 68, 0.22);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.5);
}

.status-pill.neutral {
  background: rgba(148, 163, 184, 0.16);
  color: var(--text-sub);
  border: 1px solid var(--border-subtle);
}

.status-pill.valid {
  background: rgba(255, 42, 122, 0.2);
  color: #ff85b3;
  border: 1px solid var(--border-pink);
}

/* Banners */
.alert-banner {
  max-width: 680px;
  margin: 10px auto 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid var(--accent-amber);
  color: #fde68a;
  font-size: 12px;
}

.import-banner {
  max-width: 680px;
  margin: 10px auto 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22), rgba(56, 189, 248, 0.2));
  border: 1.5px solid var(--accent-green);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.import-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  min-width: 0;
}

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

/* Main Layout */
.app-main {
  max-width: 680px;
  margin: 0 auto;
  padding: 12px 14px 24px;
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Cards */
.card {
  background: linear-gradient(165deg, rgba(25, 35, 58, 0.95) 0%, rgba(17, 24, 39, 0.98) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

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

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
}

.card-desc {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  color: #ff85b3;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

/* Segmented Control */
.segmented-control {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.segmented-control .seg-btn {
  flex: 1 1 0;
  white-space: nowrap;
}

.seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 9px 8px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

.seg-btn.active {
  background: var(--pink-grad);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(255, 42, 122, 0.35);
}

/* Form Elements */
.form-group,
.form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
}

.input-with-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.input-text,
.input-select,
.input-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-text:focus,
.input-select:focus,
.input-textarea:focus {
  border-color: var(--pink-primary);
  box-shadow: 0 0 0 2px rgba(255, 42, 122, 0.22);
}

.input-textarea {
  resize: vertical;
  font-family: inherit;
}

.mono-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

.helper-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.helper-text {
  font-size: 11px;
  color: var(--text-muted);
}

.ext-link {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
  text-decoration: underline;
}

/* Buttons */
.btn {
  appearance: none;
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

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

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

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 13px 16px;
  font-size: 14px;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 12px;
  border-radius: 9px;
}

.btn-xs {
  padding: 4px 9px;
  font-size: 11px;
  border-radius: 8px;
}

.btn-icon {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 9px 11px;
  border-radius: 10px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--pink-grad);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(255, 42, 122, 0.38);
}

.btn-secondary {
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  color: #ffffff;
}

.btn-outline {
  background: rgba(30, 41, 66, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: var(--text-main);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-x {
  background: #000000;
  border: 1px solid #334155;
  color: #ffffff;
}

.btn-threads {
  background: #18181b;
  border: 1px solid #52525b;
  color: #ffffff;
}

/* Badges & Chips */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.45);
}

.badge-warn {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.badge-info {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.45);
}

.badge-neutral {
  background: rgba(148, 163, 184, 0.16);
  color: var(--text-sub);
  border: 1px solid var(--border-subtle);
}

.badge-error {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.5);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  appearance: none;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-sub);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.chip.active {
  background: rgba(255, 42, 122, 0.22);
  border-color: var(--pink-primary);
  color: #ff85b3;
}

/* Subpanels */
.subpanel-box {
  background: rgba(11, 15, 25, 0.65);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 12px;
}

.step-heading {
  font-size: 12px;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 6px;
}

.provider-links-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.provider-link-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 10px;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.active-ai-summary {
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  font-size: 12px;
  color: var(--text-sub);
}

.imported-meta {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 42, 122, 0.12);
  border: 1px solid var(--border-pink);
  font-size: 12px;
}

/* Pipeline Progress */
.progress-bar-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-input);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.progress-bar-fill {
  height: 100%;
  background: var(--pink-grad);
  transition: width 0.25s ease;
}

.progress-msg {
  margin: 8px 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.step-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 9px;
  background: rgba(13, 19, 34, 0.7);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #475569;
  flex-shrink: 0;
}

.step-item.running {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.12);
}

.step-item.running .step-dot {
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
}

.step-item.done {
  border-color: rgba(16, 185, 129, 0.45);
}

.step-item.done .step-dot {
  background: var(--accent-green);
}

.step-item.warn {
  border-color: rgba(245, 158, 11, 0.5);
}

.step-item.warn .step-dot {
  background: var(--accent-amber);
}

.step-item.error {
  border-color: rgba(239, 68, 68, 0.6);
}

.step-item.error .step-dot {
  background: var(--accent-red);
}

.step-name {
  flex: 1;
  font-weight: 600;
}

.step-state {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

.warning-box {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid var(--accent-amber);
  color: #fde68a;
  font-size: 12px;
}

.error-box {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid var(--accent-red);
  color: #fca5a5;
  font-size: 12px;
}

/* Result & SNS */
.wp-links-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.sns-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.html-preview-details summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.html-preview-box {
  margin-top: 8px;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  max-height: 260px;
  overflow-y: auto;
}

/* History */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-card {
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
}

.history-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.history-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.history-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

/* Step 1 Guide */
.step-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--pink-grad);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-step-card {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
}

.guide-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--pink-grad);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.guide-body {
  flex: 1;
  min-width: 0;
}

.guide-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.guide-diagram {
  margin: 4px 0;
  padding: 5px 8px;
  border-radius: 7px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px dashed rgba(56, 189, 248, 0.35);
  color: #7dd3fc;
  font-size: 11px;
  font-weight: 700;
}

.guide-text {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-muted);
}

.criteria-summary-box {
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
}

.criteria-summary-title {
  font-size: 12px;
  font-weight: 800;
  color: #ff85b3;
  margin-bottom: 6px;
}

.criteria-list {
  margin: 0;
  padding-left: 18px;
  font-size: 11px;
  color: var(--text-sub);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.copy-feedback,
.test-feedback {
  margin-top: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}

.feedback-ok {
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid var(--accent-green);
  color: #6ee7b7;
}

.feedback-err {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid var(--accent-red);
  color: #fca5a5;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding-bottom: var(--safe-bottom);
  background: rgba(11, 15, 25, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-width: 680px;
  margin: 0 auto;
}

.nav-item {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  height: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.nav-item.active {
  color: #ff5e8e;
}

.nav-icon {
  font-size: 18px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: calc(74px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  width: calc(100% - 28px);
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--border-pink);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

/* Utilities */
.mt-4 { margin-top: 4px; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mb-6 { margin-bottom: 6px; }
.mb-10 { margin-bottom: 10px; }

/* Collapsible Details */
.accordion-details {
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--bg-input);
  overflow: hidden;
  transition: all 0.2s ease;
}

.accordion-details[open] {
  border-color: rgba(255, 42, 122, 0.4);
}

.accordion-summary {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.02);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.accordion-summary::-webkit-details-marker {
  display: none;
}

.accordion-summary::after {
  content: '▼';
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.accordion-details[open] .accordion-summary::after {
  transform: rotate(180deg);
  color: var(--accent-pink);
}

.accordion-content {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border-subtle);
}

/* Layout Reorder List */
.layout-order-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.layout-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  transition: all 0.15s ease;
}

.layout-item.disabled {
  opacity: 0.5;
  background: rgba(0, 0, 0, 0.2);
}

.layout-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.layout-item-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-pink);
  cursor: pointer;
}

.layout-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.layout-item-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.layout-item-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.layout-item-actions {
  display: flex;
  gap: 4px;
}

.btn-move {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-sub);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-move:hover:not(:disabled) {
  background: var(--pink-grad);
  color: #ffffff;
  border-color: transparent;
}

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

/* Media Uploader / Gallery Preview */
.media-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.media-thumb-box {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #000000;
  border: 1px solid var(--border-subtle);
}

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

.media-thumb-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  color: #ff5e62;
  border: none;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.specs-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.specs-check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-sub);
  cursor: pointer;
}
