:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #202425;
  background: #f4f6f5;
  font-synthesis: none;
  --surface: #ffffff;
  --surface-muted: #eef1ef;
  --line: #d9dfdc;
  --line-strong: #bcc6c1;
  --text: #202425;
  --muted: #65706b;
  --green: #176b4d;
  --green-soft: #e4f2eb;
  --blue: #245ca6;
  --red: #a33a32;
  --shadow: 0 12px 36px rgba(27, 42, 35, 0.08);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f4f6f5; color: var(--text); }
button, input, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 720; }
.brand-mark, .empty-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: #1f4939;
  color: white;
  font-weight: 800;
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
}
.icon-button:hover, .command-button:hover, .category-tab:hover { border-color: var(--line-strong); background: #f8faf9; }
.command-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 650;
}
.command-button.primary { background: var(--green); border-color: var(--green); color: white; }
.command-button.primary:hover { background: #115b40; border-color: #115b40; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); min-height: calc(100vh - 64px); }
.catalog { min-width: 0; padding: 32px clamp(20px, 4vw, 56px) 64px; }
.catalog-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 6px; color: var(--green); font-size: 12px; font-weight: 760; text-transform: uppercase; }
h1, h2, h3, p { letter-spacing: 0; }
h1 { margin: 0; font-size: clamp(26px, 3vw, 38px); line-height: 1.15; }
h2 { margin: 0; font-size: 24px; line-height: 1.2; }
h3 { margin: 0 0 12px; font-size: 14px; }
.result-count { margin: 0; color: var(--muted); font-size: 13px; white-space: nowrap; }

.search-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(170px, 220px) auto; gap: 10px; }
.search-field input, .select-field select, .publish-form input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.search-field input:focus, .select-field select:focus, .publish-form input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 77, 0.12); }
.category-tabs { display: flex; gap: 3px; margin: 18px 0 22px; padding-bottom: 4px; overflow-x: auto; }
.category-tab { flex: 0 0 auto; min-height: 34px; padding: 0 11px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.category-tab.active { background: var(--green-soft); color: var(--green); font-weight: 680; }

.status-banner { margin: 0 0 14px; padding: 12px 14px; border-left: 3px solid var(--red); background: #fff0ef; color: #7c2c27; font-size: 14px; }
.package-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.package-card {
  min-width: 0;
  min-height: 176px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.package-card:hover, .package-card.selected { border-color: #8da79b; box-shadow: var(--shadow); transform: translateY(-1px); }
.package-card:focus-visible { outline: 3px solid rgba(23, 107, 77, 0.2); outline-offset: 2px; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.package-card h2 { font-size: 17px; overflow-wrap: anywhere; }
.package-id { margin: 5px 0 0; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; overflow-wrap: anywhere; }
.card-summary { margin: 18px 0; color: #4d5752; font-size: 14px; line-height: 1.55; }
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 8px; border-radius: 5px; background: var(--surface-muted); color: #4f5e57; font-size: 11px; }
.version { flex: 0 0 auto; padding: 3px 7px; border-radius: 4px; background: #edf2f7; color: var(--blue); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.empty-list { grid-column: 1 / -1; padding: 56px 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); text-align: center; }
.load-more { display: block; width: 100%; min-height: 42px; margin-top: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer; }

.detail-panel { position: sticky; top: 64px; align-self: start; height: calc(100vh - 64px); overflow-y: auto; border-left: 1px solid var(--line); background: var(--surface); }
.detail-empty { display: grid; place-items: center; align-content: center; gap: 14px; min-height: 70vh; color: var(--muted); }
.detail-empty p { margin: 0; }
.detail-content { padding: 22px 24px 48px; }
.detail-toolbar { display: flex; align-items: center; justify-content: space-between; min-height: 32px; margin-bottom: 18px; }
.release-state { color: var(--green); font-size: 12px; font-weight: 700; }
.detail-summary { margin: 14px 0; color: #4d5752; line-height: 1.62; }
.detail-content > .chip-row { margin-bottom: 22px; }
.facts { display: grid; grid-template-columns: 108px minmax(0, 1fr); margin: 0; border-top: 1px solid var(--line); }
.facts dt, .facts dd { margin: 0; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { text-align: right; overflow-wrap: anywhere; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 20px 0 26px; }
.detail-section { margin-top: 26px; }
.contribution-list { display: flex; flex-wrap: wrap; gap: 6px; }
.contribution-item { padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.release-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.release-item p { margin: 3px 0 0; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; overflow-wrap: anywhere; }
.release-item time { color: var(--muted); font-size: 11px; }
.screenshot-list { display: grid; gap: 8px; }
.screenshot-list img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-muted); }
.mobile-only { display: none; }

.publish-dialog { width: min(620px, calc(100vw - 28px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--text); box-shadow: 0 24px 72px rgba(12, 28, 20, 0.22); }
.publish-dialog::backdrop { background: rgba(20, 29, 25, 0.38); backdrop-filter: blur(2px); }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { font-size: 20px; }
.publish-form { display: grid; gap: 15px; padding: 22px; }
.publish-form label { display: grid; gap: 6px; color: #4d5752; font-size: 13px; font-weight: 630; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 4px; }
.form-status { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .detail-panel { position: fixed; inset: 64px 0 0; z-index: 15; height: auto; transform: translateX(100%); transition: transform 160ms ease; border-left: 0; }
  .detail-panel.open { transform: translateX(0); }
  .detail-empty { display: none; }
  .mobile-only { display: inline-grid; }
}

@media (max-width: 640px) {
  .topbar { min-height: 58px; padding: 0 14px; }
  .brand-mark { width: 31px; height: 31px; }
  .workspace { min-height: calc(100vh - 58px); }
  .catalog { padding: 24px 14px 48px; }
  .catalog-header { align-items: flex-start; }
  .result-count { margin-top: 8px; }
  .search-row { grid-template-columns: 1fr auto; }
  .select-field { grid-column: 1 / -1; grid-row: 2; }
  .package-list { grid-template-columns: 1fr; }
  .detail-panel { inset: 58px 0 0; }
  .two-columns { grid-template-columns: 1fr; }
  .dialog-actions { align-items: stretch; flex-direction: column; }
  .dialog-actions .command-button { width: 100%; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface: #171b19;
    --surface-muted: #202623;
    --line: #303936;
    --line-strong: #46524d;
    --text: #edf2ef;
    --muted: #9aa6a0;
    --green: #4caf82;
    --green-soft: #173a2c;
    --blue: #83b6ff;
    --shadow: 0 12px 36px rgba(0, 0, 0, 0.24);
  }
  body { background: #111513; }
  .topbar { background: rgba(23, 27, 25, 0.94); }
  .command-button.primary { color: #071b12; }
  .card-summary, .detail-summary, .publish-form label { color: #c0c9c5; }
  .version { background: #202d3b; }
  .status-banner { background: #351c1b; color: #ffb5ae; }
}
