:root {
  color-scheme: dark;
  --bg: #07080c;
  --panel: rgba(16, 19, 28, 0.82);
  --panel-strong: rgba(24, 29, 42, 0.96);
  --line: rgba(255,255,255,0.095);
  --line-strong: rgba(255,255,255,0.16);
  --text: #f5f1e8;
  --muted: rgba(245,241,232,0.64);
  --faint: rgba(245,241,232,0.38);
  --opal: #a6f4c5;
  --opal-2: #7dd3fc;
  --amber: #ffc56f;
  --danger: #ff7a90;
  --shadow: 0 24px 90px rgba(0,0,0,0.44);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(166, 244, 197, 0.14), transparent 28rem),
    radial-gradient(circle at 85% 12%, rgba(125, 211, 252, 0.10), transparent 30rem),
    linear-gradient(180deg, #080a0f 0%, #090b10 52%, #050609 100%);
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
code { color: #cbfbdc; }

.app-shell { display: grid; grid-template-columns: 72px 1fr; min-height: 100vh; }
.console-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: rgba(2, 3, 6, 0.44);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 18px 12px;
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 14px;
  background: linear-gradient(145deg, rgba(166,244,197,.22), rgba(125,211,252,.10));
  border: 1px solid rgba(166,244,197,.35);
  display: grid; place-items: center;
  box-shadow: 0 0 28px rgba(166,244,197,.08);
}
.brand-mark span { width: 14px; height: 14px; border-radius: 50%; background: var(--opal); box-shadow: 0 0 28px var(--opal); }
.console-rail nav { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.console-rail button {
  width: 46px; height: 46px; border: 1px solid transparent; border-radius: 15px;
  background: transparent; color: var(--faint); cursor: pointer;
}
.console-rail button.active, .console-rail button:hover {
  background: rgba(255,255,255,0.07); color: var(--text); border-color: var(--line);
}

.workspace { width: min(1440px, 100%); margin: 0 auto; padding: 36px clamp(18px, 4vw, 56px) 56px; }
.hero { display: flex; justify-content: space-between; gap: 28px; align-items: flex-start; margin-bottom: 22px; }
.eyebrow { margin: 0 0 8px; color: var(--opal); text-transform: uppercase; letter-spacing: .13em; font-weight: 750; font-size: 11px; }
h1 { margin: 0; font-size: clamp(38px, 6vw, 82px); letter-spacing: -.07em; line-height: .92; }
h2 { margin: 0; font-size: 28px; letter-spacing: -.04em; }
.lede { color: var(--muted); max-width: 720px; font-size: 18px; line-height: 1.55; margin: 18px 0 0; }
.hero-actions { display: flex; gap: 10px; flex-shrink: 0; margin-top: 12px; }
.primary, .ghost {
  border-radius: 999px; border: 1px solid var(--line-strong); padding: 11px 16px; cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.primary { background: #f6f0df; color: #0b0d12; border-color: #f6f0df; font-weight: 760; }
.ghost { background: rgba(255,255,255,0.045); color: var(--text); }
.primary:hover, .ghost:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.28); }
.small { padding: 8px 12px; font-size: 13px; }

.research-strip {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 22px 0;
}
.research-strip article {
  border: 1px solid var(--line); background: rgba(255,255,255,0.04); border-radius: 22px; padding: 16px 18px;
}
.research-strip strong { display: block; margin-bottom: 6px; }
.research-strip span { color: var(--muted); line-height: 1.45; font-size: 14px; }

.toolbar {
  position: sticky; top: 12px; z-index: 10;
  border: 1px solid var(--line); background: rgba(11, 13, 19, 0.78); backdrop-filter: blur(22px);
  border-radius: 28px; padding: 12px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center;
}
.search-wrap {
  height: 54px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  border-radius: 20px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,.08); padding: 0 10px 0 17px;
}
.search-wrap.dragging, .dropzone.dragging { border-color: var(--opal); box-shadow: inset 0 0 0 1px rgba(166,244,197,.35); }
.search-icon { color: var(--muted); }
.search-wrap input { width: 100%; border: 0; outline: none; background: transparent; color: var(--text); }
.search-wrap button, .icon {
  border: 0; background: rgba(255,255,255,.08); border-radius: 14px; height: 36px; min-width: 36px; cursor: pointer;
}
.filter-row { display: flex; gap: 8px; align-items: center; overflow-x: auto; padding-bottom: 1px; }
select, .form-grid input, textarea, .key-create input {
  color: var(--text); background: rgba(255,255,255,0.06); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; outline: none;
}
select { min-width: 118px; }

.status-line { display: flex; justify-content: space-between; gap: 18px; align-items: center; color: var(--muted); margin: 22px 2px 14px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.pill { font-size: 12px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.04); color: var(--muted); }

.grid { columns: 4 230px; column-gap: 14px; }
.card {
  break-inside: avoid; margin: 0 0 14px; border: 1px solid var(--line); border-radius: 26px; overflow: hidden;
  background: rgba(255,255,255,.045); box-shadow: 0 16px 48px rgba(0,0,0,.18); cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.card:hover { transform: translateY(-3px); border-color: rgba(166,244,197,.34); background: rgba(255,255,255,.065); }
.thumb { position: relative; background: #10131c; }
.thumb img, .thumb video { width: 100%; display: block; height: auto; }
.badge { position: absolute; top: 10px; left: 10px; backdrop-filter: blur(12px); border-radius: 999px; padding: 6px 9px; font-size: 11px; font-weight: 750; background: rgba(0,0,0,.38); border: 1px solid rgba(255,255,255,.14); }
.play { position: absolute; right: 10px; top: 10px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: rgba(0,0,0,.46); }
.card-body { padding: 14px; }
.card-title { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 8px; }
.card-title strong { font-size: 15px; }
.score { color: var(--opal); font-variant-numeric: tabular-nums; font-size: 12px; }
.note { color: var(--muted); font-size: 13px; line-height: 1.4; margin: 0 0 10px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { color: var(--faint); font-size: 11px; border: 1px solid var(--line); padding: 4px 7px; border-radius: 999px; }
.empty-state { border: 1px dashed var(--line-strong); border-radius: 28px; padding: 34px; color: var(--muted); text-align: center; break-inside: avoid; }

.mcp-panel {
  margin-top: 28px; border: 1px solid var(--line); border-radius: 30px; padding: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.035));
  display: grid; grid-template-columns: .8fr 1.2fr; gap: 24px; align-items: start;
}
.mcp-panel p:not(.eyebrow) { color: var(--muted); line-height: 1.5; }
.mcp-console { border-radius: 20px; overflow: hidden; background: #05070b; border: 1px solid rgba(255,255,255,.1); }
.mcp-command { display: flex; justify-content: space-between; gap: 12px; padding: 12px; border-bottom: 1px solid rgba(255,255,255,.08); align-items: center; }
.mcp-command button { border: 0; border-radius: 999px; background: var(--opal); color: #061009; padding: 8px 12px; font-weight: 760; cursor: pointer; }
pre { margin: 0; padding: 14px; overflow: auto; color: #d9f8e5; font-size: 12px; line-height: 1.45; max-height: 360px; white-space: pre-wrap; overflow-wrap: anywhere; }
.mcp-command code { white-space: normal; overflow-wrap: anywhere; }

.modal { border: 0; background: transparent; padding: 0; width: min(680px, calc(100vw - 24px)); color: var(--text); }
.modal::backdrop { background: rgba(0,0,0,.66); backdrop-filter: blur(12px); }
.modal-card { border: 1px solid var(--line-strong); background: rgba(16,19,28,.96); border-radius: 30px; box-shadow: var(--shadow); padding: 20px; display: grid; gap: 16px; }
.modal-card header { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.dropzone { border: 1px dashed var(--line-strong); background: rgba(255,255,255,.04); border-radius: 24px; padding: 28px; text-align: center; cursor: pointer; display: grid; gap: 8px; }
.dropzone input { display: none; }
.dropzone small { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label, .modal-card > label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
textarea { min-height: 92px; resize: vertical; }
.upload-preview { min-height: 120px; border-radius: 20px; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; color: var(--muted); background: rgba(0,0,0,.2); }
.upload-preview img, .upload-preview video { max-width: 100%; max-height: 260px; display: block; }
.modal-card footer { display: flex; justify-content: flex-end; gap: 10px; }
.key-create { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; }
.checkbox { color: var(--muted); display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.new-key { border: 1px solid rgba(166,244,197,.32); background: rgba(166,244,197,.08); color: #dfffe9; border-radius: 18px; padding: 13px; word-break: break-all; }
.key-list { display: grid; gap: 10px; }
.key-row { display: flex; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 16px; padding: 12px; color: var(--muted); }
.key-row strong { color: var(--text); }
.key-row button { border: 0; border-radius: 999px; background: rgba(255,122,144,.14); color: #ffc5cf; padding: 7px 10px; cursor: pointer; }

.detail-panel {
  position: fixed; inset: 0 0 0 auto; width: min(520px, 100vw); transform: translateX(105%); transition: transform .25s ease;
  z-index: 30; background: rgba(11,13,19,.96); border-left: 1px solid var(--line-strong); box-shadow: var(--shadow); overflow: auto; padding: 22px;
}
.detail-panel.open { transform: translateX(0); }
.close-detail { position: sticky; top: 0; margin-left: auto; display: block; z-index: 2; }
.detail-media { border-radius: 26px; overflow: hidden; border: 1px solid var(--line); background: #05070b; margin: 14px 0 18px; }
.detail-media img, .detail-media video { width: 100%; display: block; }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.meta { border: 1px solid var(--line); border-radius: 16px; padding: 10px; }
.meta span { display: block; color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 5px; }
.similar-list { display: grid; gap: 10px; }
.similar-item { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 16px; padding: 8px; cursor: pointer; }
.similar-item img { width: 64px; height: 84px; object-fit: cover; border-radius: 11px; }
.similar-item strong { display: block; }
.similar-item span { color: var(--muted); font-size: 12px; }

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .console-rail { display: none; }
  .workspace { padding: 24px 14px 42px; }
  .hero { flex-direction: column; }
  .hero-actions { width: 100%; }
  .hero-actions button { flex: 1; }
  .research-strip, .toolbar, .mcp-panel { grid-template-columns: 1fr; }
  .toolbar { position: static; border-radius: 24px; }
  .filter-row { width: 100%; }
  .status-line { flex-direction: column; align-items: flex-start; }
  .grid { columns: 1; }
  .form-grid, .key-create { grid-template-columns: 1fr; }
  h1 { font-size: 52px; }
}
