:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #eef2f6;
  --text: #151922;
  --muted: #667085;
  --border: #d8dee7;
  --accent: #0f8b8d;
  --accent-strong: #096a6c;
  --accent-soft: #dff4f1;
  --danger: #c2410c;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

:root.dark {
  color-scheme: dark;
  --bg: #111318;
  --panel: #1b1f27;
  --panel-soft: #242a35;
  --text: #eef2f7;
  --muted: #a6b0c0;
  --border: #343b48;
  --accent: #48c9b0;
  --accent-strong: #8ddfd1;
  --accent-soft: #173a38;
  --danger: #fb923c;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.app-shell {
  min-height: 100vh;
  padding: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  max-width: 1680px;
  margin: 0 auto 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 16px;
}

.top-actions,
.mini-actions,
.section-title,
.tool-grid,
.mode-switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.secondary-button,
.section-title > button,
.mini-actions button,
.tool-grid button {
  background: var(--panel-soft);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(230px, 300px) minmax(420px, 1fr) minmax(340px, 460px);
  gap: 16px;
  max-width: 1680px;
  margin: 0 auto;
  align-items: start;
}

.sidebar,
.library-panel,
.composer > section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar,
.library-panel,
.prompt-card,
.tools-panel,
.favorites-panel {
  padding: 14px;
}

.sidebar {
  position: sticky;
  top: 16px;
}

.search-box {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-box input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 0 12px;
}

.tabs {
  display: grid;
  gap: 6px;
  margin: 14px 0;
  max-height: 44vh;
  overflow: auto;
  padding-right: 4px;
}

.tabs button {
  justify-content: space-between;
  display: flex;
  align-items: center;
  text-align: left;
  background: transparent;
}

.tabs button.active,
.mode-switch button.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 700;
}

.quick-panel {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.section-title {
  justify-content: space-between;
  margin-bottom: 12px;
}

.random-preview {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 14px;
}

.library-panel {
  min-height: calc(100vh - 112px);
}

.mode-switch {
  background: var(--panel-soft);
  border-radius: 7px;
  padding: 3px;
}

.mode-switch button {
  border: 0;
  background: transparent;
  min-height: 30px;
}

.tag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.category {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-soft);
}

.category h3 {
  margin: 0;
  padding: 10px 12px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
}

.tag {
  display: inline-grid;
  gap: 2px;
  max-width: 100%;
  min-height: 38px;
  text-align: left;
  background: var(--panel);
  padding: 6px 8px;
}

.tag strong,
.tag span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag strong {
  font-size: 13px;
}

.tag span {
  color: var(--muted);
  font-size: 12px;
}

.composer {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 16px;
}

.prompt-card.primary {
  border-color: rgba(15, 139, 141, 0.5);
}

textarea {
  width: 100%;
  min-height: 122px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 12px;
  line-height: 1.55;
}

textarea:focus,
input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 30px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid rgba(15, 139, 141, 0.28);
}

.chip button {
  width: 18px;
  min-height: 18px;
  padding: 0;
  border-radius: 50%;
  color: inherit;
  background: transparent;
}

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

.favorites-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.favorite-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px;
  background: var(--panel-soft);
}

.favorite-item p {
  margin: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--text);
  color: var(--bg);
  border-radius: 7px;
  padding: 10px 14px;
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 280px 1fr;
  }

  .composer {
    grid-column: 1 / -1;
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tools-panel,
  .favorites-panel {
    grid-column: span 1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .workspace,
  .composer {
    display: grid;
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }

  .sidebar {
    position: static;
  }

  .tabs {
    max-height: none;
  }

  .library-panel {
    min-height: auto;
  }

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