:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-2: #eef4f1;
  --text: #17211c;
  --muted: #65726c;
  --border: #d9e2dd;
  --accent: #35a894;
  --accent-strong: #147b6e;
  --amber: #c98418;
  --rose: #df6a74;
  --indigo: #5967cf;
  --shadow: 0 18px 48px rgba(16, 25, 21, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101512;
  --surface: #17201b;
  --surface-2: #1e2b25;
  --text: #eff5f2;
  --muted: #aab8b2;
  --border: #304039;
  --accent: #4fc7b2;
  --accent-strong: #77ddcb;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(53, 168, 148, 0.08), transparent 260px),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

.svg-sprite {
  display: none;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

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

.side-nav {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  padding: 18px 16px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand img {
  border-radius: 8px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 18px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.category-nav {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding-right: 2px;
}

.category-button,
.side-link,
.primary-action,
.pill,
.segment,
.icon-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease, color 160ms ease;
}

.category-button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  text-align: left;
}

.category-button:hover,
.side-link:hover,
.featured-card:hover,
.tool-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.category-button.active,
.pill.active,
.segment.active {
  border-color: color-mix(in srgb, var(--category-accent, var(--accent)) 70%, var(--border));
  background: color-mix(in srgb, var(--category-accent, var(--accent)) 12%, var(--surface));
}

.category-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--category-accent, var(--accent));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--category-accent, var(--accent)) 16%, transparent);
}

.category-copy {
  min-width: 0;
}

.category-copy strong,
.category-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.category-count {
  color: var(--muted);
  font-size: 12px;
}

.side-links {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  color: var(--muted);
}

.workspace {
  width: min(calc(100% - clamp(32px, 5vw, 96px)), 1680px);
  margin: 0 auto;
  padding: 24px clamp(24px, 2vw, 40px) 36px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 920px;
  margin-bottom: 0;
  font-size: clamp(30px, 3.2vw, 46px);
  line-height: 1.08;
  letter-spacing: 0;
}

.topbar-actions,
.surface-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.icon-button,
.segment {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
}

.icon-button:hover,
.segment:hover,
.pill:hover {
  border-color: var(--accent);
}

.theme-moon,
:root[data-theme="dark"] .theme-sun {
  display: none;
}

:root[data-theme="dark"] .theme-moon {
  display: block;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--text);
  color: var(--surface);
  font-weight: 700;
}

:root[data-theme="dark"] .primary-action {
  background: var(--accent);
  color: #07110d;
}

.command-surface {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  padding: 0 12px;
}

.search-box .icon {
  color: var(--muted);
}

.search-box input {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
}

.segmented {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.segment {
  width: 38px;
  height: 38px;
  border-color: transparent;
  background: transparent;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.stat-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
}

.stat-item strong,
.stat-item span {
  display: block;
}

.stat-item strong {
  font-size: 25px;
}

.stat-item span {
  color: var(--muted);
}

.filter-row,
.tag-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filter-row {
  margin-bottom: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
}

.pill span {
  color: color-mix(in srgb, var(--muted) 70%, transparent);
  font-size: 12px;
}

.featured-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.featured-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.featured-card img,
.tool-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--surface-2);
}

.featured-card strong,
.featured-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.featured-card small {
  color: var(--muted);
  font-size: 12px;
}

.featured-card .icon {
  color: var(--muted);
}

.tools-area {
  display: grid;
  gap: 26px;
}

.tool-section {
  display: grid;
  gap: 12px;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-heading h2 {
  margin-bottom: 2px;
  font-size: 20px;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
}

.section-heading > span:last-child {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}

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

.tool-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 148px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  transition: transform 160ms ease, border-color 160ms ease;
}

.tool-main {
  display: flex;
  gap: 12px;
  min-width: 0;
}

.tool-copy {
  min-width: 0;
}

.tool-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-bottom: 8px;
}

.tool-title-row h3 {
  overflow: hidden;
  margin-bottom: 0;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-category {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.tool-copy p {
  display: -webkit-box;
  overflow: hidden;
  min-height: 42px;
  margin-bottom: 12px;
  color: var(--muted);
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tool-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tool-tags span {
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}

.tool-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.favorite-button.active {
  border-color: color-mix(in srgb, var(--amber) 70%, var(--border));
  background: color-mix(in srgb, var(--amber) 16%, var(--surface));
  color: var(--amber);
}

.list-view .tool-grid {
  grid-template-columns: 1fr;
}

.list-view .tool-card {
  min-height: auto;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 28px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
  font-size: 18px;
}

.form-page {
  min-height: 100vh;
  padding: 28px;
}

.simple-header,
.form-layout,
.about-layout {
  width: min(100%, 1040px);
  margin: 0 auto;
}

.simple-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}

.simple-nav {
  display: flex;
  gap: 10px;
}

.simple-nav a {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.form-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
  align-items: start;
}

.form-panel,
.queue-panel,
.about-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form-panel,
.about-panel {
  padding: 24px;
}

.form-panel h1,
.about-panel h1 {
  margin-bottom: 8px;
  font-size: 34px;
  line-height: 1.1;
}

.form-panel > p,
.about-panel > p {
  color: var(--muted);
  line-height: 1.7;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

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

.field label {
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
}

.field input,
.field select {
  height: 44px;
  padding: 0 12px;
}

.field textarea {
  min-height: 108px;
  resize: vertical;
  padding: 12px;
}

.field small {
  color: var(--muted);
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #07110d;
}

.queue-panel {
  overflow: hidden;
}

.queue-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.queue-panel h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.submission-list {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
  padding: 16px;
}

.submission-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.submission-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.submission-item span {
  color: var(--muted);
  font-size: 13px;
}

.about-layout {
  display: grid;
  gap: 18px;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.about-item {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.about-item strong {
  display: block;
  margin-bottom: 8px;
}

.about-item span {
  color: var(--muted);
  line-height: 1.6;
}

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

  .side-nav {
    position: static;
    height: auto;
    padding: 18px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .category-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
    overflow: visible;
  }

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

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

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

@media (max-width: 720px) {
  .workspace,
  .form-page {
    padding: 18px;
  }

  .topbar,
  .simple-header,
  .command-surface {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 34px;
  }

  .topbar-actions,
  .surface-actions,
  .simple-nav {
    width: 100%;
  }

  .primary-action,
  .simple-nav a {
    flex: 1;
    justify-content: center;
  }

  .stats-row,
  .field-grid,
  .about-grid {
    grid-template-columns: 1fr;
  }

  .category-nav {
    grid-template-columns: 1fr;
  }

  .featured-strip {
    grid-template-columns: 1fr;
  }

  .tool-card {
    grid-template-columns: 1fr;
  }

  .tool-actions {
    flex-direction: row;
  }
}
