:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #181b20;
  --panel-soft: #20242b;
  --text: #f4f1ea;
  --muted: #a9b0bc;
  --line: #323842;
  --accent: #39d98a;
  --accent-strong: #2fc279;
  --accent-ink: #07140d;
  --warn: #f4c95d;
  --danger: #ff7a7a;
  --shadow: rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(57, 217, 138, 0.16), transparent 32rem),
    linear-gradient(145deg, #101114 0%, #16191f 56%, #121412 100%);
}

a {
  color: inherit;
}

button,
textarea {
  font: inherit;
}

.center-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.home-card,
.tool-card,
.browser-shell {
  width: min(920px, 100%);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 60px var(--shadow);
}

.home-card {
  max-width: 440px;
  padding: 28px;
  text-align: center;
}

.home-card h1,
.tool-card h1,
.browser-header h1 {
  margin: 0;
  letter-spacing: 0;
}

.home-card h1 {
  font-size: 40px;
  line-height: 1;
}

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

.button-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.button,
.segmented button,
.icon-button,
.sort-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-soft);
  text-decoration: none;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.button {
  padding: 0 14px;
}

.button.primary,
.segmented button.active,
.sort-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.button:hover,
.segmented button:hover,
.icon-button:hover,
.sort-button:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.browser-page {
  min-height: 100vh;
  padding: 24px;
}

.browser-shell {
  margin: 0 auto;
  padding: 22px;
}

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

.browser-header h1 {
  font-size: 28px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.toolbar-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar-label {
  color: var(--muted);
  font-size: 13px;
}

.sort-button {
  padding: 0 12px;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d0f12;
}

.segmented button {
  min-width: 70px;
  min-height: 32px;
  padding: 0 10px;
}

.file-list,
.file-grid,
.tool-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.file-list {
  display: grid;
  gap: 10px;
}

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

.file-list[hidden],
.file-grid[hidden] {
  display: none;
}

.file-link,
.tool-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  color: var(--text);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.file-link {
  min-height: 58px;
  padding: 10px 12px;
}

.tool-link {
  min-height: 64px;
  padding: 12px;
}

.file-link:hover,
.tool-link:hover {
  border-color: var(--accent);
  background: #242a31;
  transform: translateY(-1px);
}

.file-kind {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 8px;
  background: rgba(57, 217, 138, 0.15);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.file-main,
.tool-main {
  min-width: 0;
  flex: 1;
}

.file-name,
.tool-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.file-meta,
.tool-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.file-grid .file-link {
  min-height: 144px;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  padding: 12px;
}

.file-grid .file-main {
  width: 100%;
}

.file-grid .file-name {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.thumb {
  width: 82px;
  height: 82px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0d0f12;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.tool-card {
  padding: 22px;
}

.tool-card h1 {
  font-size: 24px;
  text-align: center;
}

.tool-card textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  padding: 12px;
  color: var(--text);
  background: #0d0f12;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.tool-card textarea:focus {
  border-color: var(--accent);
}

.tool-stack {
  display: grid;
  gap: 14px;
}

.tool-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.status-line {
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.status-line.error {
  color: var(--danger);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.84);
  z-index: 10;
}

.modal.open {
  display: flex;
}

.modal-body {
  max-width: min(1100px, 96vw);
  max-height: 90vh;
  display: grid;
  gap: 10px;
  justify-items: center;
}

.modal-content {
  max-width: 100%;
  max-height: 82vh;
}

.modal-content img,
.modal-content video {
  display: block;
  max-width: 100%;
  max-height: 82vh;
  border-radius: 8px;
  box-shadow: 0 20px 60px var(--shadow);
}

.modal-content audio {
  width: min(560px, 86vw);
}

.modal-content iframe {
  width: min(1100px, 92vw);
  height: 82vh;
  border: 0;
  border-radius: 8px;
  background: white;
}

.modal-content pre {
  width: min(980px, 92vw);
  max-height: 76vh;
  overflow: auto;
  margin: 0;
  padding: 16px;
  color: #15171a;
  background: #f4f1ea;
  border-radius: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.modal-caption {
  max-width: 88vw;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
}

@media (max-width: 620px) {
  .center-shell,
  .browser-page {
    padding: 14px;
  }

  .home-card,
  .tool-card,
  .browser-shell {
    padding: 16px;
  }

  .home-card h1 {
    font-size: 34px;
  }

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

  .toolbar {
    align-items: stretch;
  }

  .toolbar-group {
    width: 100%;
  }

  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  }

  .file-grid .file-link {
    min-height: 124px;
  }

  .thumb {
    width: 64px;
    height: 64px;
  }
}
