@font-face {
  font-family: Montserrat;
  src: url('/panel-assets/montserrat-cyrillic.woff2') format('woff2');
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: Montserrat;
  src: url('/panel-assets/montserrat-latin.woff2') format('woff2');
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #f5f5ee;
  --charcoal: #141515;
  --accent: #1b1c1c;
  --ink: #181918;
  --muted: #565852;
  --on-dark: #dedfd7;
  --surface: #eaeae4;
  --surface-hover: #ddded6;
  --radius: 10px;
  --shell: calc(100% - 2 * clamp(12px, 1.8vw, 36px));
  background: var(--paper);
  color: var(--ink);
  font-family: Montserrat, 'Segoe UI', Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-underline-offset: .22em; }
:focus-visible { outline: 2px solid #444642; outline-offset: 4px; }
.top :focus-visible { outline-color: var(--on-dark); }

.top {
  background: var(--charcoal);
  color: var(--paper);
}
.top-inner {
  width: var(--shell);
  min-height: 58px;
  margin-inline: auto;
  padding-block: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
}
.brand {
  color: inherit;
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 9px;
  font: 650 1.7rem/1 Bahnschrift, 'Segoe UI', Arial, sans-serif;
  letter-spacing: -.045em;
  text-decoration: none;
}
.brand-mark {
  width: 32px;
  height: 32px;
  background: currentColor;
  mask: url('/panel-assets/kilson.svg') center / contain no-repeat;
}
#who:not(:empty) {
  min-width: 0;
  padding: 9px 12px;
  border-radius: 8px;
  background: #30322f;
  color: #edeee8;
  font-size: .82rem;
  overflow-wrap: anywhere;
}
.account {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}
.account-exit {
  border: 0;
  border-radius: 8px;
  padding: 10px;
  color: var(--paper);
  background: transparent;
  font: 650 .82rem Montserrat, 'Segoe UI', Arial, sans-serif;
  cursor: pointer;
}
.account-exit:hover { background: #30322f; }

#view {
  width: var(--shell);
  margin-inline: auto;
  padding-block: clamp(32px, 6vw, 78px) 64px;
}
h1, h2, p { margin: 0; }
h1 {
  font-size: clamp(2.4rem, 6vw, 5.75rem);
  font-weight: 750;
  line-height: 1.04;
  letter-spacing: -.055em;
  overflow-wrap: anywhere;
}
h2 {
  margin-block: 28px 12px;
  font-size: clamp(1.35rem, 2.3vw, 2.1rem);
  font-weight: 750;
  line-height: 1.14;
  letter-spacing: -.035em;
}
.sub {
  margin-block: 12px 24px;
  color: var(--muted);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.card {
  min-width: 0;
  padding: clamp(16px, 2.6vw, 30px);
  margin-block: 12px;
  border-radius: 14px;
  background: #fcfcf8;
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
}
.row + .row { margin-top: 8px; }
.row > :first-child { min-width: 0; overflow-wrap: anywhere; }
.name {
  margin-bottom: 4px;
  font-weight: 700;
  letter-spacing: -.025em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  max-width: 100%;
  padding: 11px 17px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: 700 .87rem/1.35 Montserrat, 'Segoe UI', Arial, sans-serif;
  text-align: center;
  text-decoration: none;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: background-color .18s ease, transform .18s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); background: #393a38; }
.btn:active:not(:disabled) { transform: none; }
.btn.sec { color: var(--accent); background: var(--surface); }
.row .btn.sec { background: #fcfcf8; }
.btn.sec:hover:not(:disabled) { background: var(--surface-hover); }
.btn.danger { background: #f9e5e7; color: #831f31; }
.btn.danger:hover:not(:disabled) { background: #f2d4d9; }
.btn:disabled { opacity: .55; cursor: default; }
.btn + .btn { margin-inline-start: 6px; }

.box {
  min-width: 0;
  margin-block: 12px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  font-size: .94rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.box.warn { background: #f9e5e7; color: #831f31; }
pre.creds {
  max-width: 100%;
  overflow: auto;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--charcoal);
  color: #edeee8;
  font-size: .86rem;
  line-height: 1.65;
}

input, select, textarea {
  display: block;
  width: 100%;
  min-height: 46px;
  margin-block: 6px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
select { appearance: none; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  border-color: #444642;
  outline: 2px solid #44464232;
  outline-offset: 1px;
  background: #fff;
}
label { display: block; font-size: .88rem; font-weight: 650; }
.field { margin-block: 0 14px; }
.dim {
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
#filelist { margin-bottom: 14px; }
#filelist a { display: inline-block; padding-block: 4px; }
#chatinfo:not(:empty), #deployinfo:not(:empty), #seclist:not(:empty) { margin-top: 12px; }
.err, .ok {
  margin-block: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: .88rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.err { background: #f9e5e7; color: #831f31; }
.ok { background: #e3f0e8; color: #174d35; }
.spacer { height: 18px; }

body:has(#view > #login) {
  background: var(--charcoal);
  color: var(--paper);
}
#view:has(> #login) {
  display: flex;
  position: relative;
  z-index: 1;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: calc(100svh - 58px);
  padding-bottom: clamp(50px, 9vw, 130px);
}
body:has(#view > #login)::after {
  content: '';
  position: fixed;
  z-index: 0;
  inset: auto 0 0 auto;
  width: min(49vw, 690px);
  aspect-ratio: 1;
  background: #30322e;
  mask: url('/panel-assets/kilson.svg') left top / 116% no-repeat;
  pointer-events: none;
}
#view:has(> #login) h1 { font-size: clamp(3.25rem, 10vw, 9rem); line-height: .98; }
#view:has(> #login) h1 span { color: var(--on-dark); }
#view:has(> #login) .sub {
  margin-block: 24px;
  color: #edeee8;
  font-size: clamp(1rem, 1.5vw, 1.22rem);
}
#login { background: var(--on-dark); color: var(--charcoal); }
#login:hover:not(:disabled) { background: #f1f2ec; }
#login:focus-visible { outline-color: var(--on-dark); }

#list { padding: 0; background: transparent; }
#list > .dim {
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius);
}

.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  width: fit-content;
  max-width: 100%;
  margin: 24px 0;
  overflow-x: auto;
  border-radius: 12px;
  background: var(--surface);
}
.tabs button {
  flex: none;
  min-height: 42px;
  padding: 8px 15px;
  border: 0;
  border-radius: 8px;
  color: var(--accent);
  background: transparent;
  font-weight: 700;
  font-size: .89rem;
  scroll-margin-inline: 6px;
}
.tabs button:hover { background: var(--surface-hover); }
.tabs button[aria-selected="true"] { background: var(--accent); color: #fff; }
.tabs button:focus-visible { outline-offset: -3px; outline-color: #858882; }
[hidden] { display: none !important; }
.tab-panel { border-radius: var(--radius); }
.workspace {
  display: grid;
  grid-template-columns: clamp(165px, 15vw, 245px) minmax(0, 1fr);
  align-items: start;
  gap: clamp(12px, 1.5vw, 28px);
}
.workspace-title { font-size: clamp(1.35rem, 2.2vw, 2.6rem); }
#view:has(> .workspace) { padding-block: 0; display: flex; flex-direction: column; min-height: calc(100dvh - 58px); }
.workspace .tabs {
  position: sticky;
  top: 20px;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  margin: 0;
  padding: 8px;
}
.workspace .tabs button { text-align: left; }
.workspace > .tab-panel { min-width: 0; }
.workspace > .tab-panel > .card:first-child { margin-top: 0; }
.overview-card .actions { margin-top: 17px; }
.card > .workspace-note { margin-top: 14px; }
.project-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 88px;
  padding: 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.project-card:hover { background: var(--surface-hover); }
.project-card:disabled { opacity: .65; cursor: progress; }
.project-card .name, .project-card .dim { display: block; overflow-wrap: anywhere; }
.project-card .name { font-size: 1rem; }
.project-card .open { color: var(--accent); font-size: .82rem; font-weight: 700; }
.tab-panel .card h2 { margin-top: 0; }
.tab-panel .card > p { line-height: 1.55; overflow-wrap: anywhere; }
.back-link {
  margin: 0 0 16px;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: 650 .9rem/1.4 Montserrat, 'Segoe UI', Arial, sans-serif;
}
.back-link:hover { text-decoration: underline; text-underline-offset: .23em; }
.project-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 10px;
}
.project-list .row { margin: 0; min-height: 82px; }
.overview-card { width: 100%; }
.panel-form,
.upload-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
}
.panel-form .long { grid-column: 1 / -1; min-width: 0; }
.panel-form > .field { margin: 0; min-width: 0; }
.details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  gap: 12px;
  margin: 18px 0;
}
.details > div { border-radius: var(--radius); padding: 12px; background: var(--surface); }
.details dt { color: var(--muted); font-size: .83rem; }
.details dd { margin: 6px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.actions .btn + .btn { margin: 0; }
.frontend-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 14px;
  align-items: start;
}
.file-list {
  display: grid;
  gap: 5px;
  max-height: 350px;
  overflow: auto;
  padding: 3px;
  margin: -3px -3px 16px;
}
.file-list button {
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  color: var(--accent);
  background: var(--surface);
  font: .85rem/1.4 ui-monospace, Consolas, monospace;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.file-list button:hover { background: var(--surface-hover); }
.file-list button[aria-pressed="true"] { color: #fff; background: var(--accent); }
.file-list button:focus-visible { outline-offset: 1px; }
.inline-form button { margin-top: 4px; }
.code-editor {
  font: .92rem/1.55 ui-monospace, Consolas, monospace;
  min-height: 245px;
}
.upload-inputs { margin-top: 12px; }
#frontend-upload { scroll-margin-top: 20px; }
input[type="file"] { min-width: 0; width: 100%; font-size: .82rem; }
input[type="file"]::file-selector-button {
  padding: 7px 10px;
  margin-inline-end: 8px;
  border: 0;
  border-radius: 6px;
  background: #fcfcf8;
  color: var(--accent);
  font: 650 .82rem Montserrat, 'Segoe UI', Arial, sans-serif;
  cursor: pointer;
}
fieldset {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 0;
  margin: 8px 0;
  border: 0;
}
legend { margin-bottom: 8px; font-weight: 700; }
fieldset label { display: inline-flex; align-items: center; gap: 6px; }
input:is([type="checkbox"], [type="radio"]) {
  width: 1em;
  min-height: 0;
  margin: 0;
  accent-color: var(--accent);
}
#versions, #seclist { margin-bottom: 14px; }
#versions ul, .secret-list ul { padding-left: 20px; overflow-wrap: anywhere; }
#upload-status { white-space: pre-wrap; }

@media (max-width: 740px) {
  .frontend-layout, .panel-form, .upload-inputs { grid-template-columns: minmax(0, 1fr); }
  .frontend-layout { gap: 0; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .workspace .tabs { position: static; flex-direction: row; width: fit-content; }
}

@media (max-width: 540px) {
  body:has(#view > #login)::after {
    width: min(68vw, 330px);
    mask-size: 120%;
    opacity: .72;
  }
  .top-inner { min-height: 58px; }
  .account #who { display: none; }
  #view:has(> #login) { min-height: calc(100svh - 58px); }
  .btn + .btn { margin: 8px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .btn:hover:not(:disabled) { transform: none; }
}

.project-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 18px; padding: 16px 0; }
.project-heading .back-link, .project-heading .sub { margin: 0; }
.workspace { flex: 1; padding-bottom: 12px; }
#view:has(#builder:not([hidden])) { height: calc(100dvh - 58px); }
.workspace:has(#builder:not([hidden])) { min-height: 0; grid-template-rows: minmax(0, 1fr); }
#builder { height: 100%; min-height: 0; }
.chat { height: 100%; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; background: #fcfcf8; border-radius: 14px; overflow: hidden; }
.chat-head, .chat-compose { padding: 14px clamp(12px, 2vw, 32px); }
.chat-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.chat-head h2 { margin: 0; font-size: 1.25rem; }
#chatlog { overflow: auto; overscroll-behavior: contain; padding: 12px clamp(12px, 3vw, 56px); }
.chat-empty { height: 100%; display: grid; align-content: center; justify-items: center; gap: 15px; text-align: center; }
.chat-empty strong { font-size: clamp(1.45rem, 3vw, 3.2rem); letter-spacing: -.055em; }
.msg { width: fit-content; max-width: min(88%, 80ch); margin: 0 0 18px; overflow-wrap: anywhere; }
.msg strong { display: block; margin-bottom: 5px; font-size: .75rem; color: var(--muted); }
.msg p { margin: 0; padding: 12px 16px; background: var(--surface); border-radius: 4px 16px 16px; line-height: 1.55; white-space: pre-wrap; }
.msg.user { margin-left: auto; }
.msg.user strong { text-align: right; }
.msg.user p { background: var(--accent); color: white; border-radius: 16px 4px 16px 16px; }
.msg details { padding: 8px 0; color: var(--muted); font-size: .8rem; line-height: 1.6; }
.msg summary { width: fit-content; cursor: pointer; font-weight: 600; }
.builder-activity { display: flex; align-items: center; gap: .5em; margin-bottom: .45rem; color: var(--muted); font-size: .8rem; }
.builder-activity::before { content: ""; width: .55em; height: .55em; border-radius: 50%; background: currentColor; animation: builder-pulse 1.15s ease-in-out infinite alternate; }
@keyframes builder-pulse { from { opacity: .35; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .builder-activity::before { animation: none; } }
.chat-compose { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.chat-entry { display: flex; align-items: end; gap: 8px; padding: 8px; background: var(--surface); border-radius: 14px; }
.chat-entry textarea { flex: 1 1 0; min-width: 0; width: auto; border: 0; margin: 0; min-height: 44px; max-height: 16vh; resize: none; font-size: 1rem; }
.chat-entry .btn { flex: 0 0 auto; white-space: nowrap; overflow-wrap: normal; }
.chat-compose { width: min(100%, 980px); margin-inline: auto; }
.project-map header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.map-root { width: fit-content; margin: 24px auto 0; border-radius: 10px; padding: 12px 18px; background: var(--accent); color: white; font-weight: 700; }
.map-branches { display: grid; gap: 16px; grid-template-columns: repeat(3,minmax(0,1fr)); }
.map-branch { min-width: 0; position: relative; padding-top: 26px; }
.map-branch::before { content: ""; position: absolute; top: 14px; left: 50%; height: 12px; width: 1px; background: var(--muted); }
.map-branch::after { content: ""; position: absolute; top: 14px; left: -8px; right: -8px; height: 1px; background: var(--muted); }
.map-branch:first-child::after { left: 50%; }
.map-branch:last-child::after { right: 50%; }
.map-branch:nth-child(2)::before { top: 0; height: 26px; }
.map-branch h3 { text-align: center; margin: 6px 0 12px; }
.map-node { display: grid; gap: 6px; width: 100%; margin-bottom: 8px; padding: 14px; text-align: left; color: inherit; background: var(--surface); border: 0; border-radius: 10px; font: inherit; cursor: pointer; }
.map-node:hover { background: var(--surface-hover); }
@media (max-width: 740px) {
  .map-branches { grid-template-columns: 1fr; }
  .map-root { margin-inline: 0; }
  .map-branch { padding-top: 8px; }
  .map-branch h3 { text-align: left; }
  .map-branch::after,.map-branch::before { display: none; }
}
.chat-entry:focus-within { outline: 2px solid var(--accent); }
.chat-entry textarea:focus { background: transparent; outline: none; }
.chat-compose .err, .chat-compose .ok { margin: 0; }
#chatinfo:not(:empty) { margin: 0; }
.record-list { display: grid; gap: 6px; }
.tab-panel[inert] { cursor: progress; opacity: .75; }
#fn-url, #fn-last, #fn-output { overflow-wrap: anywhere; white-space: pre-wrap; }
#fn-jobs, #schema-columns, #access-users { margin-block: 12px; }
.record-list > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 18px; padding: 10px 14px; background: var(--surface); border-radius: 8px; }
.record-list > div strong { margin-right: auto; }
@media (max-width: 740px) {
  .workspace:has(#builder:not([hidden])) { grid-template-rows: auto minmax(0, 1fr); }
  .project-heading { padding: 8px 0; gap: 4px 10px; }
  .project-heading .sub { display: none; }
  .workspace .tabs { width: 100%; }
  .chat-head, .chat-compose { padding: 10px; }
}
