/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
:root {
  --bg-base:    #0a0a0f;
  --bg-surface: #13131a;
  --bg-panel:   #1a1a24;
  --bg-hover:   #22222f;
  --bg-active:  #2a2a3d;
  --border:     #2a2a3d;
  --border-light: #3a3a50;
  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --text-muted:   #55556a;
  --accent:     #7c6af7;
  --accent-light: #9d8fff;
  --accent-dark:  #5a4fd4;
  --success:    #22c55e;
  --warning:    #f59e0b;
  --danger:     #ef4444;
  --current:    #7c6af7;
  --archive:    #6b7280;
  --testing:    #f59e0b;
}

html, body { height: 100%; margin: 0; padding: 0; }
body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Layout ── */
#app { display: flex; flex-direction: column; height: 100vh; }

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 52px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}
.app-header .logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-light);
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-header .logo span { font-size: 20px; }
.header-search {
  flex: 1;
  max-width: 400px;
  margin-left: auto;
  position: relative;
}
.header-search input {
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px 6px 34px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.header-search input:focus { border-color: var(--accent); }
.header-search .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 12px;
  pointer-events: none;
}
.header-actions { display: flex; gap: 8px; margin-left: 12px; }

.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 256px;
  min-width: 256px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-section { padding: 8px 0; }
.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 6px;
  margin: 1px 6px;
  color: var(--text-secondary);
  transition: all 0.15s;
  font-size: 13px;
  user-select: none;
}
.sidebar-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-item.active {
  background: var(--bg-active);
  color: var(--accent-light);
  font-weight: 500;
}
.sidebar-item .item-icon { width: 16px; text-align: center; font-size: 13px; flex-shrink: 0; }
.sidebar-item .item-badge {
  margin-left: auto;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
}
.sidebar-item.active .item-badge { background: var(--accent-dark); color: var(--accent-light); }
.sidebar-item .item-badge-zero { color: var(--text-muted); opacity: 0.35; }

/* Category tree */
.cat-toggle { cursor: pointer; color: var(--text-muted); font-size: 10px; transition: transform 0.2s; }
.cat-toggle.open { transform: rotate(90deg); }
.cat-children { padding-left: 16px; }

.sidebar-tags { padding: 4px 12px 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  background: var(--bg-panel);
  color: var(--text-secondary);
}
.tag-chip:hover { border-color: var(--border-light); color: var(--text-primary); }
.tag-chip.active { color: #fff; border-color: transparent; }
.tag-dot { width: 6px; height: 6px; border-radius: 50%; }
.tag-delete-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
  font-size: 9px;
  cursor: pointer;
  padding: 0;
  margin-left: 2px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.tag-chip:hover .tag-delete-btn { display: inline-flex; }
.tag-delete-btn:hover { background: var(--danger); color: #fff; }

/* ── Prompt List ── */
.content-area {
  flex: 1;
  display: flex;
  overflow: hidden;
}
.prompt-list-panel {
  width: 300px;
  min-width: 300px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
}
.list-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.list-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.list-count { font-size: 12px; color: var(--text-muted); }
.prompt-list { flex: 1; overflow-y: auto; padding: 4px; }
.prompt-card {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.prompt-card:hover { background: var(--bg-surface); border-color: var(--border); }
.prompt-card.selected { background: var(--bg-panel); border-color: var(--accent); }
.prompt-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prompt-card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.prompt-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.prompt-card-meta .tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 500;
  color: #fff;
}
.fav-icon { color: var(--warning); font-size: 11px; }
.prompt-card-date { font-size: 10px; color: var(--text-muted); margin-left: auto; }
.forked-badge {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ── Editor Panel ── */
.editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
}
.editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
}
.editor-empty .icon { font-size: 48px; opacity: 0.3; }
.editor-empty p { font-size: 14px; }

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.editor-title-input {
  font-size: 18px;
  font-weight: 700;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  flex: 1;
  min-width: 200px;
}
.editor-toolbar-actions { display: flex; gap: 6px; margin-left: auto; align-items: center; }

/* Version tabs */
.version-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}
.version-bar-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}
.version-select {
  background: var(--bg-panel);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
  max-width: 300px;
}
.version-select:hover { border-color: var(--accent); }
.version-select:focus { border-color: var(--accent); }
.btn-accent {
  background: var(--accent-dark);
  color: #fff;
  border: none;
}
.btn-accent:hover { background: var(--accent); }
.version-status-dot { width: 7px; height: 7px; border-radius: 50%; }
.status-current { background: var(--current); }
.status-archive { background: var(--archive); }
.status-testing { background: var(--testing); }
.add-version-btn {
  margin-left: auto;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.add-version-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.editor-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}
.editor-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.prompt-textarea {
  flex: 1;
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.8;
  padding: 16px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* ── Variable Simulator ── */
.var-panel {
  width: 280px;
  min-width: 280px;
  border-left: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.var-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.var-panel-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.var-panel-body { flex: 1; overflow-y: auto; padding: 12px; }
.var-item { margin-bottom: 12px; }

/* ヘッダー行：ラベル + モード切替ボタン */
.var-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}
.var-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-light);
  font-family: monospace;
  line-height: 1;
}

/* モード切替ボタングループ */
.var-mode-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px;
}
.var-mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 20px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
}
.var-mode-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.var-mode-btn.active { background: var(--accent-dark); color: #fff; }

/* シングルライン入力 */
.var-input {
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.var-input:focus { border-color: var(--accent); }

/* マルチライン入力（textarea） */
.var-textarea {
  resize: vertical;
  min-height: 90px;
  max-height: 240px;
  line-height: 1.6;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 11px;
}
.var-preview {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.var-preview-label { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.var-preview-content {
  background: var(--bg-panel);
  border-radius: 6px;
  padding: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow-y: auto;
  font-family: monospace;
}
.var-preview-content .var-highlight { color: var(--accent-light); font-weight: 600; }
.copy-preview-btn {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  background: var(--accent-dark);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.copy-preview-btn:hover { background: var(--accent); }
.no-vars { font-size: 12px; color: var(--text-muted); text-align: center; padding: 16px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-light); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 4px 8px; font-size: 12px; border-radius: 5px; }
.btn-icon { padding: 6px 8px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 24px;
  width: 480px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}
.modal-lg { width: 640px; }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ── Form ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-textarea, .form-select {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.form-input:focus, .form-textarea:focus, .form-select:focus { border-color: var(--accent); }
.form-textarea { resize: vertical; min-height: 120px; line-height: 1.6; font-family: inherit; }
.form-select option { background: var(--bg-panel); }

/* Tags selector */
.tags-selector { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-option {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all 0.15s;
}
.tag-option.selected { border-color: transparent; color: #fff; }

/* ── Share modal ── */
.share-url-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 12px;
}
.share-url { flex: 1; font-size: 12px; color: var(--text-secondary); word-break: break-all; font-family: monospace; }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary);
  min-width: 240px;
  animation: slideInRight 0.25s ease;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--accent); }
.toast-warning { border-left: 3px solid var(--warning); }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Tabs ── */
.editor-meta-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 16px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}
.meta-tab {
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.meta-tab.active { color: var(--accent-light); border-bottom-color: var(--accent); }
.meta-tab:hover:not(.active) { color: var(--text-primary); }

.meta-pane { padding: 12px 16px; }
.meta-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.meta-key { font-size: 11px; color: var(--text-muted); min-width: 60px; }

/* ── Empty state ── */
.empty-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Shared page ── */
.shared-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px;
}
.shared-header { margin-bottom: 24px; }
.shared-title { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.shared-desc { font-size: 14px; color: var(--text-secondary); }
.shared-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: monospace;
}
.shared-var-highlight { color: var(--accent-light); font-weight: 600; }

/* ── Tooltip (JS-driven) ── */
#js-tooltip {
  position: fixed;
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 5px;
  white-space: nowrap;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.12s ease;
}
#js-tooltip.visible { opacity: 1; }

/* ── Note input ── */
.version-note-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--text-secondary);
  font-size: 11px;
  outline: none;
}
.version-note-input:focus { border-color: var(--accent); }

/* ── Auth Page ── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  padding: 20px;
}
.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}
.auth-logo {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-light);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}
.auth-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}
.auth-tabs {
  display: flex;
  gap: 0;
  background: var(--bg-base);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  text-align: center;
  padding: 7px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}
.auth-tab.active { background: var(--bg-active); color: var(--text-primary); }
.auth-error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 12px;
  color: #fca5a5;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.auth-success {
  background: rgba(34,197,94,.12);
  border: 1px solid rgba(34,197,94,.3);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 12px;
  color: #86efac;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.auth-link {
  color: var(--accent-light);
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
}
.auth-link:hover { text-decoration: underline; }

/* ── Account / Admin Page ── */
.settings-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px;
}
.settings-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.settings-title { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.settings-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
  overflow: hidden;
}
.settings-section-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-body { padding: 20px; }

/* Avatar */
.avatar-picker {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 16px;
}
.avatar-img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--bg-active);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-light);
  border: 2px solid var(--border-light);
  overflow: hidden;
  flex-shrink: 0;
}
.avatar-img img { width: 100%; height: 100%; object-fit: cover; }

/* User table */
.user-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.user-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.user-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.user-table tr:last-child td { border-bottom: none; }
.user-table tr:hover td { background: var(--bg-hover); }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
}
.badge-admin { background: rgba(124,106,247,.2); color: var(--accent-light); }
.badge-active { background: rgba(34,197,94,.15); color: #86efac; }
.badge-inactive { background: rgba(239,68,68,.15); color: #fca5a5; }

/* Header user menu */
.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.15s;
  position: relative;
}
.header-user:hover { background: var(--bg-hover); }
.header-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-active);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-light);
  border: 1px solid var(--border-light);
  overflow: hidden;
  flex-shrink: 0;
}
.header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.header-username { font-size: 13px; font-weight: 500; color: var(--text-primary); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Dropdown menu */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 6px;
  min-width: 200px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 9000;
  animation: fadeIn 0.12s ease;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.12s;
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-item.danger { color: #fca5a5; }
.dropdown-item.danger:hover { background: rgba(239,68,68,.12); color: #ef4444; }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Password strength */
.pw-strength { height: 3px; border-radius: 2px; margin-top: 6px; transition: all 0.3s; }
.pw-strength-0 { width: 0%; background: transparent; }
.pw-strength-1 { width: 25%; background: #ef4444; }
.pw-strength-2 { width: 50%; background: #f59e0b; }
.pw-strength-3 { width: 75%; background: #3b82f6; }
.pw-strength-4 { width: 100%; background: #22c55e; }
.pw-strength-label { font-size: 10px; color: var(--text-muted); margin-top: 3px; }

/* ── Auth form controls ── */
.auth-form { display: block; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.form-control:focus { border-color: var(--accent); }

/* Password input wrapper */
.input-password-wrap { position: relative; }
.input-password-wrap .form-control { padding-right: 38px; }
.btn-show-pw {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}
.btn-show-pw:hover { color: var(--text-secondary); }

/* Block button */
.btn-block { width: 100%; justify-content: center; margin-top: 4px; }

/* Password strength bar */
.pw-strength {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.pw-strength-bar {
  height: 100%;
  width: 0;
  border-radius: 2px;
  transition: width 0.3s, background 0.3s;
}
.pw-strength-label { font-size: 10px; margin-top: 3px; transition: color 0.3s; }

/* Settings section title */
.settings-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 20px;
  padding: 16px 20px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Settings section inner padding */
.settings-section > *:not(.settings-section-title) {
  padding-left: 20px;
  padding-right: 20px;
}
.settings-section > .settings-section-title + * { padding-top: 0; }
.settings-section > *:last-child { padding-bottom: 20px; }

/* Dropdown open state */
.dropdown-menu { display: none; }
.dropdown-menu.open { display: block; }
.header-user { user-select: none; position: relative; }

/* Category action buttons (hover to show) */
.cat-item .cat-actions {
  display: none;
  align-items: center;
  gap: 2px;
  margin-right: 4px;
}
.cat-item:hover .cat-actions {
  display: flex;
}
.cat-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1;
  opacity: 0.7;
}
.cat-action-btn:hover {
  background: var(--bg-hover);
  opacity: 1;
}


/* ══════════════════════════════════════════════
   Store Page
   ══════════════════════════════════════════════ */
.store-page {
  display: flex;
  height: calc(100vh - 52px);
  overflow: hidden;
}
.store-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 0;
}
.store-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.store-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}
.store-sort-btn.active {
  background: var(--bg-hover);
  color: var(--accent);
}
.store-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  align-content: start;
}

/* Store Card */
.store-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.store-card-icon-wrap {
  display: flex;
  justify-content: center;
  padding-bottom: 4px;
}
.store-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
  user-select: none;
}
.store-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.store-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.store-card-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.4;
}
.store-card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.store-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.store-author {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}
.store-author-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}
.store-author-initial {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Badge */
.store-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(99,102,241,.18);
  color: var(--accent);
}
.store-badge-other {
  background: rgba(100,116,139,.18);
  color: var(--text-muted);
}

/* Like button */
.store-like-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.store-like-btn:hover { border-color: #ef4444; color: #ef4444; }
.store-like-btn.liked  { border-color: #ef4444; color: #ef4444; background: rgba(239,68,68,.08); }

/* Content preview */
.store-content-preview {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-secondary);
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: monospace;
}

/* Store modal overlay */
#store-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* ── Icon Palette ─────────────────────────────────────── */
.icon-palette-genre {
  margin-bottom: 10px;
}
.icon-palette-genre:last-child {
  margin-bottom: 0;
}
.icon-palette-genre-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.icon-palette-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.icon-palette-btn {
  width: 34px;
  height: 34px;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  border: 1.5px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  transition: all .12s;
  padding: 0;
  user-select: none;
}
.icon-palette-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  transform: scale(1.15);
}
.icon-palette-btn.selected {
  background: rgba(99,102,241,.18);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99,102,241,.35);
}

/* ── Icon Picker shared UI ────────────────────────────── */
.ip-preview {
  font-size: 22px;
  min-width: 28px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}
.ip-ai-area {
  margin-bottom: 4px;
}
.ip-palette-wrap {
  margin-bottom: 4px;
}
.ip-palette-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  justify-content: space-between;
  transition: border-color .15s;
}
.ip-palette-toggle:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}
.ip-palette-panel {
  margin-top: 8px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--bg-panel);
}

/* ── EasyMDE ダークテーマ ─────────────────────────────────── */
.EasyMDEContainer {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.EasyMDEContainer .CodeMirror {
  background: var(--bg-base);
  color: var(--text-primary);
  border: none;
  border-top: 1px solid var(--border);
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  line-height: 1.7;
  height: 100%;
  flex: 1;
}
.EasyMDEContainer .CodeMirror-scroll {
  min-height: 100%;
}
.EasyMDEContainer .CodeMirror-cursor {
  border-left-color: var(--accent-light);
}
.EasyMDEContainer .CodeMirror-selected {
  background: rgba(99,102,241,.25);
}
/* ツールバー */
.editor-toolbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  border-top: none;
  padding: 4px 8px;
}
.editor-toolbar button {
  color: var(--text-secondary) !important;
  border: none !important;
  background: transparent !important;
  border-radius: 6px !important;
}
.editor-toolbar button:hover,
.editor-toolbar button.active {
  background: var(--bg-panel) !important;
  color: var(--text-primary) !important;
}
.editor-toolbar i.separator {
  border-left-color: var(--border) !important;
}
/* プレビューエリア */
.EasyMDEContainer .editor-preview,
.EasyMDEContainer .editor-preview-side {
  background: var(--bg-panel);
  color: var(--text-primary);
  border-left: 1px solid var(--border);
  padding: 16px 20px;
  font-size: 13px;
  line-height: 1.8;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', 'Menlo', monospace;
}
.EasyMDEContainer .editor-preview h1,
.EasyMDEContainer .editor-preview h2,
.EasyMDEContainer .editor-preview h3,
.EasyMDEContainer .editor-preview h4,
.EasyMDEContainer .editor-preview h5,
.EasyMDEContainer .editor-preview h6,
.EasyMDEContainer .editor-preview-side h1,
.EasyMDEContainer .editor-preview-side h2,
.EasyMDEContainer .editor-preview-side h3,
.EasyMDEContainer .editor-preview-side h4,
.EasyMDEContainer .editor-preview-side h5,
.EasyMDEContainer .editor-preview-side h6 {
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-top: 16px;
  margin-bottom: 8px;
  font-weight: 700;
  line-height: 1.3;
}
.EasyMDEContainer .editor-preview h1,
.EasyMDEContainer .editor-preview-side h1 { font-size: 2.2em; }
.EasyMDEContainer .editor-preview h2,
.EasyMDEContainer .editor-preview-side h2 { font-size: 1.75em; }
.EasyMDEContainer .editor-preview h3,
.EasyMDEContainer .editor-preview-side h3 { font-size: 1.4em;  border-bottom: none; }
.EasyMDEContainer .editor-preview h4,
.EasyMDEContainer .editor-preview-side h4 { font-size: 1.15em; border-bottom: none; }
.EasyMDEContainer .editor-preview h5,
.EasyMDEContainer .editor-preview-side h5 { font-size: 0.95em; border-bottom: none; }
.EasyMDEContainer .editor-preview h6,
.EasyMDEContainer .editor-preview-side h6 { font-size: 0.8em;  border-bottom: none; color: var(--text-muted); }
.EasyMDEContainer .editor-preview code,
.EasyMDEContainer .editor-preview-side code {
  background: var(--bg-surface);
  color: #a5b4fc;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}
.EasyMDEContainer .editor-preview pre,
.EasyMDEContainer .editor-preview-side pre {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
}
.EasyMDEContainer .editor-preview pre code,
.EasyMDEContainer .editor-preview-side pre code {
  background: none;
  padding: 0;
}
.EasyMDEContainer .editor-preview table,
.EasyMDEContainer .editor-preview-side table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
}
.EasyMDEContainer .editor-preview th,
.EasyMDEContainer .editor-preview td,
.EasyMDEContainer .editor-preview-side th,
.EasyMDEContainer .editor-preview-side td {
  border: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 12px;
}
.EasyMDEContainer .editor-preview th,
.EasyMDEContainer .editor-preview-side th {
  background: var(--bg-surface);
  color: var(--text-secondary);
}
.EasyMDEContainer .editor-preview blockquote,
.EasyMDEContainer .editor-preview-side blockquote {
  border-left: 3px solid var(--accent);
  margin: 8px 0;
  padding: 4px 12px;
  color: var(--text-muted);
}
/* サイドバイサイドモード */
.EasyMDEContainer.sided .CodeMirror-wrap {
  border-right: 1px solid var(--border);
}
/* フルスクリーン */
.EasyMDEContainer.fullscreen {
  z-index: 9999;
  background: var(--bg-base);
}
/* エディタ本体のラッパーを高さいっぱいに */
.editor-main .EasyMDEContainer {
  height: 100%;
}
.editor-main .CodeMirror {
  height: 100% !important;
}
