/* ── Variables ── */
:root {
  --bg:       #ffffff;
  --bg2:      #f8f9fa;
  --bg3:      #eef0f2;
  --text:     #1a1a2e;
  --text2:    #6b7280;
  --border:   #e2e4e8;
  --accent:   #f97316;
  --accent-h: #ea6c0b;
  --danger:   #ef4444;
  --success:  #22c55e;
  --shadow:   0 1px 4px rgba(0,0,0,.08);
  --radius:   12px;
  --radius-sm:8px;
  --chip-h:   44px;
}

[data-theme="dark"] {
  --bg:       #0f172a;
  --bg2:      #1e293b;
  --bg3:      #334155;
  --text:     #e2e8f0;
  --text2:    #94a3b8;
  --border:   #334155;
  --shadow:   0 1px 4px rgba(0,0,0,.3);
}

/* ── Reset / Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100dvh;
  transition: background .25s, color .25s;
}

/* ── Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(249,115,22,.35);
}

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

.app-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  background: rgba(255,255,255,.2);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.35); }

/* ── Favorites Bar ── */
.favorites-bar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (min-width: 600px) {
  .favorites-bar { flex-direction: row; align-items: center; flex-wrap: wrap; }
}

.fav-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.fav-select {
  flex: 1;
  min-width: 140px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  padding: 0 8px;
  font-size: 13px;
  cursor: pointer;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, opacity .12s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--bg3); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12px; }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-h); border-color: var(--accent-h); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
[data-theme="dark"] .btn-danger:hover { background: #3f1515; }

.text-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.text-btn:hover { opacity: .75; }

/* ── Tabs ── */
.tabs-wrapper {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 64px;
  z-index: 90;
}

.tabs {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
}

.tab {
  flex: 1;
  padding: 13px 8px;
  border: none;
  background: none;
  color: var(--text2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Mode Content ── */
.mode-content {
  display: none;
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px 48px;
}
.mode-content.active { display: block; }

/* ── Accordion Controls ── */
.accordion-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.divider-dot { color: var(--text2); }

/* ── Accordion ── */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.accordion-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s;
}
.accordion-header:hover { background: var(--bg2); }

.acc-icon {
  font-size: 12px;
  color: var(--text2);
  transition: transform .2s;
  flex-shrink: 0;
}
.accordion-header[aria-expanded="true"] .acc-icon {
  transform: rotate(90deg);
}

.acc-title { flex: 1; }

.acc-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--accent);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.accordion-body {
  padding: 4px 16px 16px;
  border-top: 1px solid var(--border);
}

/* ── Chip Group ── */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.chip input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.chip span {
  display: inline-flex;
  align-items: center;
  height: var(--chip-h);
  padding: 0 16px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--bg2);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: background .12s, border-color .12s, color .12s;
  user-select: none;
}

.chip:hover span {
  border-color: var(--accent);
  background: var(--bg3);
}

.chip:has(input:checked) span,
.chip.checked span {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Comment Row ── */
.comment-row {
  margin-top: 10px;
}

/* ── Text Inputs ── */
.text-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color .15s, box-shadow .15s;
  resize: vertical;
}
.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249,115,22,.15);
}
.text-input::placeholder { color: var(--text2); }

.textarea-sm { min-height: 64px; }
.textarea-md { min-height: 80px; }

/* ── Field Label / Hint ── */
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-top: 12px;
  margin-bottom: 4px;
}
.field-label:first-child { margin-top: 8px; }

.field-hint {
  font-size: 13px;
  color: var(--text2);
  padding: 12px 0 4px;
}

/* ── Style Description ── */
.style-desc {
  font-size: 13px;
  color: var(--text2);
  background: var(--bg2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 8px 12px;
  margin-top: 10px;
  min-height: 0;
  transition: opacity .2s;
}
.style-desc:empty { display: none; }

/* ── Generate Button ── */
.generate-wrap {
  margin: 24px 0 8px;
}

.generate-btn {
  width: 100%;
  height: 56px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 4px 14px rgba(249,115,22,.4);
  -webkit-tap-highlight-color: transparent;
}
.generate-btn:hover {
  background: var(--accent-h);
  box-shadow: 0 6px 18px rgba(249,115,22,.5);
}
.generate-btn:active { transform: scale(.98); }

/* ── Output ── */
.output-section {
  margin-top: 20px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}

.output-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.output-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
}

.output-note {
  font-size: 12px;
  color: var(--text2);
}

.output-textarea {
  display: block;
  width: 100%;
  min-height: 260px;
  padding: 16px;
  border: none;
  background: var(--bg2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.7;
  resize: vertical;
  cursor: text;
}
.output-textarea:focus { outline: none; }

.copy-btn {
  display: block;
  width: 100%;
  height: 52px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.copy-btn:hover { background: var(--accent-h); }
.copy-btn.copied { background: var(--success); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #1a1a2e;
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  z-index: 9999;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
[data-theme="dark"] .toast { background: #e2e8f0; color: #1a1a2e; }

/* ── Footer ── */
.app-footer {
  text-align: center;
  padding: 24px 16px 40px;
  color: var(--text2);
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .app-title { font-size: 15px; }
  .tab { font-size: 13px; padding: 12px 6px; }
  .chip span { height: 40px; padding: 0 13px; font-size: 13px; }
  .generate-btn { height: 52px; font-size: 16px; }
  .copy-btn { height: 48px; font-size: 15px; }
}
