:root {
  color-scheme: dark;
  --bg-primary: #151619;
  --bg-secondary: #242528;
  --bg-tertiary: #3b3c44;
  --bg-hover: #30343a;
  --border-color: #3d4047;
  --text-primary: #f4f7fb;
  --text-secondary: #b9c0cb;
  --text-muted: #838b98;
  --accent-blue: #60a5fa;
  --accent-blue-strong: #2f85ee;
  --accent-purple: #b47af5;
  --accent-yellow: #f7c948;
  --accent-green: #64d185;
  --accent-pink: #fb7185;
  --shadow: 0 20px 45px rgba(0, 0, 0, .38);
  --sidebar-width: 280px;
  --header-height: 64px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg-primary: #f7f8fb;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e9edf4;
  --bg-hover: #eef4ff;
  --border-color: #d8dee9;
  --text-primary: #17202b;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --shadow: 0 20px 45px rgba(15, 23, 42, .16);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  background: var(--bg-primary);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 16px;
  z-index: 50;
}

.google-button,
.new-item-button,
.nav-item,
.new-folder-form button,
.icon-button,
.round-add-button,
.button-like,
.sort-select {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

.google-button {
  width: 100%;
  min-height: 40px;
  border-radius: 6px;
  background: var(--accent-blue);
  color: #07111f;
  font-weight: 700;
}

.google-mark {
  font-weight: 900;
}

.new-item-button {
  width: 100%;
  min-height: 48px;
  margin: 32px 0 26px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-primary);
  font-weight: 700;
}

.new-item-button:hover,
.button-like:hover,
.icon-button:hover,
.sort-select:hover {
  background: var(--bg-hover);
  border-color: var(--accent-blue);
}

.nav-section {
  margin-bottom: 28px;
}

.section-label {
  margin: 0 0 10px;
  color: var(--text-secondary);
  font-weight: 700;
  font-size: .9rem;
}

.nav-item {
  width: calc(100% + 32px);
  margin-left: -16px;
  min-height: 42px;
  padding: 0 16px;
  justify-content: flex-start;
  background: transparent;
  color: var(--text-primary);
  font-weight: 700;
}

.nav-item svg {
  width: 18px;
  height: 18px;
}

.nav-item.active {
  background: var(--accent-blue);
  color: #07111f;
}

.nav-count {
  margin-left: auto;
  color: currentColor;
  opacity: .82;
  font-size: .82rem;
  font-weight: 600;
}

.folder-list {
  display: grid;
  gap: 4px;
}

.new-folder-form {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.new-folder-form input,
.new-folder-form button {
  min-height: 40px;
  border-radius: 6px;
}

.new-folder-form input {
  width: 100%;
  border: 1px dashed var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  padding: 0 12px;
}

.new-folder-form button {
  border: 1px dashed var(--border-color);
  background: transparent;
  color: var(--text-secondary);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip {
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: .82rem;
  cursor: pointer;
}

.tag-chip:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.main-content {
  min-width: 0;
}

.main-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(21, 22, 25, .93);
  backdrop-filter: blur(14px);
}

[data-theme="light"] .main-header {
  background: rgba(247, 248, 251, .92);
}

.main-header h1 {
  margin: 0;
  font-size: 1.42rem;
  line-height: 1.1;
  white-space: nowrap;
}

.header-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.icon-button,
.round-add-button,
.button-like,
.sort-select {
  border: 1px solid transparent;
  background: var(--bg-tertiary);
  min-height: 40px;
  border-radius: 8px;
  padding: 0 12px;
}

.icon-button {
  width: 44px;
  padding: 0;
}

.round-add-button {
  width: 40px;
  border-radius: 50%;
  background: var(--accent-blue);
  color: #07111f;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  min-width: min(240px, 30vw);
}

.search-wrapper svg {
  position: absolute;
  left: 12px;
  width: 18px;
  color: var(--text-secondary);
}

.search-wrapper input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 0 12px 0 38px;
}

.sort-select {
  border-color: var(--border-color);
  color: var(--text-primary);
}

.content-view {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 48px 0;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 240px;
  color: var(--text-secondary);
  text-align: center;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.prompt-card,
.metric-card,
.panel,
.history-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.prompt-card {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.prompt-card header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.prompt-card h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.prompt-card p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.5;
}

.prompt-meta,
.chip-row,
.card-actions,
.history-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.prompt-meta {
  color: var(--text-muted);
  font-size: .82rem;
}

.chip {
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--accent-blue);
  background: color-mix(in srgb, var(--accent-blue) 12%, transparent);
  font-size: .78rem;
  font-weight: 700;
}

.card-actions {
  justify-content: flex-end;
}

.card-actions .button-like {
  min-height: 34px;
  padding: 0 10px;
  font-size: .86rem;
}

.button-primary {
  background: var(--accent-blue);
  color: #07111f;
}

.button-danger {
  background: color-mix(in srgb, var(--accent-pink) 22%, var(--bg-tertiary));
  color: var(--text-primary);
}

.editor-view {
  display: grid;
  gap: 26px;
}

.editor-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.editor-header h2 {
  margin: 0;
  font-size: 1.6rem;
}

.editor-actions {
  margin-left: auto;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.field {
  display: grid;
  gap: 8px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--text-secondary);
  font-weight: 700;
  font-size: .9rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  padding: 12px 14px;
}

.field textarea {
  min-height: 300px;
  resize: vertical;
  line-height: 1.55;
}

.checkbox-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  border-radius: 8px;
  padding: 14px;
  background: var(--bg-tertiary);
}

.checkbox-row.field {
  display: flex;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.field-tools {
  display: flex;
  justify-content: flex-end;
}

.dashboard-header {
  margin-bottom: 30px;
}

.dashboard-header h2 {
  margin: 0 0 8px;
  font-size: 1.8rem;
}

.dashboard-header p {
  margin: 0;
  color: var(--text-secondary);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.metric-card {
  min-height: 98px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
}

.metric-icon.blue {
  background: color-mix(in srgb, var(--accent-blue) 16%, transparent);
  color: var(--accent-blue);
}

.metric-icon.purple {
  background: color-mix(in srgb, var(--accent-purple) 16%, transparent);
  color: var(--accent-purple);
}

.metric-icon.yellow {
  background: color-mix(in srgb, var(--accent-yellow) 16%, transparent);
  color: var(--accent-yellow);
}

.metric-icon.green {
  background: color-mix(in srgb, var(--accent-green) 16%, transparent);
  color: var(--accent-green);
}

.metric-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
}

.metric-label {
  display: block;
  color: var(--text-secondary);
  font-size: .84rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.panel {
  padding: 24px;
  min-height: 180px;
}

.panel.wide {
  grid-column: 1 / -1;
}

.panel h3 {
  margin: 0 0 18px;
}

.chart {
  height: 260px;
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 8px;
  align-items: end;
  padding-top: 24px;
  border-bottom: 1px solid var(--border-color);
}

.bar {
  min-height: 3px;
  background: linear-gradient(180deg, var(--accent-blue), color-mix(in srgb, var(--accent-blue) 20%, transparent));
  border-radius: 999px 999px 0 0;
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-item {
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.history-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent-blue) 15%, transparent);
  color: var(--accent-blue);
}

.history-text {
  min-width: 0;
}

.history-title {
  font-weight: 800;
}

.history-meta {
  color: var(--text-secondary);
  font-size: .82rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(3px);
  padding: 18px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: min(620px, 100%);
  max-height: min(720px, 92vh);
  overflow: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  box-shadow: var(--shadow);
}

.modal-header {
  height: 58px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.tabs {
  display: flex;
  gap: 12px;
  padding: 16px 18px 0;
  border-bottom: 1px solid var(--border-color);
}

.tab {
  padding: 10px 8px;
  background: transparent;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.tab.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
}

.modal-body {
  padding: 22px 18px 28px;
}

.setting-item {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}

.setting-item p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.45;
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2000;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 240px;
  padding: 12px 16px;
  border-left: 4px solid var(--accent-blue);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: var(--shadow);
}

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

.sidebar-overlay {
  display: none;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(var(--sidebar-width), 82vw);
    transform: translateX(-100%);
    transition: transform .2s ease;
  }

  .app-shell[data-sidebar="open"] .sidebar {
    transform: translateX(0);
  }

  .app-shell[data-sidebar="open"] .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(0, 0, 0, .58);
  }

  .mobile-menu-button {
    display: inline-flex;
  }

  .header-controls {
    gap: 8px;
  }

  .search-wrapper {
    min-width: 180px;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1025px) {
  .mobile-menu-button {
    display: none;
  }
}

@media (max-width: 640px) {
  .main-header {
    height: auto;
    min-height: var(--header-height);
    align-items: flex-start;
    padding: 12px;
    flex-wrap: wrap;
  }

  .main-header h1 {
    font-size: 1.16rem;
    padding-top: 9px;
  }

  .header-controls {
    width: 100%;
    margin-left: 0;
    display: grid;
    grid-template-columns: 40px 1fr 40px;
  }

  .header-controls .sort-select {
    grid-column: 1 / -1;
    width: 100%;
  }

  .content-view {
    width: calc(100% - 28px);
    padding: 28px 0;
  }

  .editor-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .editor-actions {
    margin-left: 0;
    width: 100%;
  }

  .editor-actions .button-like {
    flex: 1 1 auto;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .prompt-grid {
    grid-template-columns: 1fr;
  }

  .toast-region {
    left: 14px;
    right: 14px;
  }
}
