/* style.css */
:root {
  --bg: #0f172a;
  --bg-soft: #111827;
  --surface: #1f2937;
  --surface-soft: #111827;
  --accent: #38bdf8;
  --accent-soft: #0ea5e9;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --border-subtle: rgba(148,163,184,0.35);
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-soft: 0 18px 40px rgba(15,23,42,0.6);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Noto Sans JP", sans-serif;
  background: radial-gradient(circle at top, #020617 0, #020617 60%, #000 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 100vh;
}

/* Sidebar */

.sidebar {
  border-right: 1px solid rgba(15,23,42,0.9);
  background: radial-gradient(circle at top left, #020617 0, #020617 60%, #000 100%);
  padding: 20px 18px;
  color: #e5e7eb;
}

.sidebar-header h1 {
  font-size: 20px;
  margin: 0 0 4px;
}

.sidebar-header p {
  margin: 0 0 16px;
  font-size: 12px;
  color: #9ca3af;
}

/* Search */

.search-panel {
  margin-bottom: 10px;
}

.search-panel label {
  display: block;
  font-size: 11px;
  margin-bottom: 4px;
  color: #9ca3af;
}

.search-panel input {
  width: 100%;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid rgba(55,65,81,1);
  background: #020617;
  color: #e5e7eb;
  font-size: 12px;
}

/* Filters */

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 12px;
}

.filter-btn {
  border-radius: 999px;
  border: 1px solid rgba(31,41,55,0.9);
  background: rgba(15,23,42,0.9);
  color: #9ca3af;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
}

.filter-btn.active {
  border-color: var(--accent);
  color: #e5e7eb;
  background: rgba(15,23,42,1);
}

/* AI Panel */

.ai-panel {
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(15,23,42,0.9);
  border: 1px solid rgba(31,41,55,0.9);
}

.ai-panel label {
  display: block;
  font-size: 11px;
  margin-bottom: 4px;
  color: #9ca3af;
}

.ai-panel input {
  width: 100%;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid rgba(55,65,81,1);
  background: #020617;
  color: #e5e7eb;
  font-size: 12px;
  margin-bottom: 6px;
}

.ai-panel input:focus,
.search-panel input:focus {
  outline: none;
  border-color: var(--accent);
}

.ai-btn {
  width: 100%;
  padding: 7px 10px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #020617;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* Palette list */

.palette-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 260px);
  overflow-y: auto;
  padding-right: 4px;
}

.palette-item {
  border-radius: 14px;
  padding: 10px;
  background: rgba(15,23,42,0.9);
  border: 1px solid rgba(31,41,55,0.9);
  cursor: pointer;
  transition: 0.18s ease;
  position: relative;
}

.palette-item:hover {
  transform: translateY(-1px);
  border-color: rgba(55,65,81,1);
}

.palette-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56,189,248,0.4);
}

.palette-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.palette-item-name {
  font-size: 13px;
  font-weight: 600;
}

.palette-item-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(31,41,55,1);
  color: #9ca3af;
}

.palette-swatches {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

.palette-swatch {
  height: 18px;
  border-radius: 6px;
  border: 1px solid rgba(15,23,42,0.7);
}

/* Favorite star */

.favorite-toggle {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 14px;
  cursor: pointer;
  color: #6b7280;
}

.favorite-toggle.active {
  color: #facc15;
}

/* Preview */

.preview {
  padding: 20px 26px 24px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  transition: background 0.2s ease, color 0.2s ease;
}

.preview[data-theme="dark"] {
  filter: saturate(1.05);
}

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

.logo {
  font-weight: 700;
  font-size: 18px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid rgba(15,23,42,0.9);
}

.nav {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 0;
}

.nav a:hover {
  color: var(--text);
}

.nav-cta {
  padding: 7px 14px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #0b1120;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* Toolbar */

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--text-muted);
  gap: 12px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-btn {
  position: relative;
  width: 70px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.6);
  background: var(--surface-soft);
  cursor: pointer;
  padding: 0;
}

.toggle-btn::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #f9fafb;
  transition: transform 0.18s ease;
}

.toggle-btn.dark::before {
  transform: translateX(42px);
}

.toggle-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
}

.accent-panel {
  display: flex;
  align-items: center;
  gap: 6px;
}

.accent-panel label {
  font-size: 11px;
}

#accentOverride {
  width: 32px;
  height: 22px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid rgba(148,163,184,0.6);
  background: transparent;
}

.accent-reset {
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.6);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
}

.export-row {
  display: flex;
  gap: 8px;
}

.export-btn {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.6);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
}

/* Hero */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 20px;
  margin-bottom: 22px;
}

.hero-text h2 {
  font-size: 26px;
  margin: 0 0 8px;
}

.hero-text p {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--text-muted);
}

.hero-actions {
  display: flex;
  gap: 10px;
}

.btn-primary,
.btn-ghost {
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: #020617;
  font-weight: 600;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: rgba(148,163,184,0.5);
}

.hero-card {
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  padding: 14px 14px 12px;
  font-size: 13px;
}

.hero-card h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.hero-card p {
  margin: 0 0 10px;
  color: var(--text-muted);
}

.stat-row {
  display: flex;
  gap: 10px;
}

.stat {
  flex: 1;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid rgba(15,23,42,0.9);
}

.stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 14px;
  font-weight: 600;
}

/* Cards */

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.card {
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  padding: 12px 12px 10px;
  font-size: 13px;
}

.card h4 {
  margin: 0 0 6px;
  font-size: 14px;
}

.card p {
  margin: 0 0 10px;
  color: var(--text-muted);
}

.card-btn {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.6);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

/* AI description */

.ai-desc-section {
  margin-top: 4px;
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid rgba(15,23,42,0.9);
  font-size: 12px;
}

.ai-desc-section h4 {
  margin: 0 0 4px;
  font-size: 13px;
}

/* Footer */

.preview-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(15,23,42,0.9);
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  gap: 8px;
}

.footer-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.footer-right {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Responsive */

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid rgba(15,23,42,0.9);
    max-height: 360px;
  }
  .palette-list {
    max-height: 230px;
  }
}

@media (max-width: 720px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .preview {
    padding: 16px;
  }
  .preview-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
