:root {
  color-scheme: dark;
  --bg: #070b12;
  --panel: rgba(16, 23, 34, .92);
  --line: #304052;
  --text: #f4f7fb;
  --muted: #aab6c7;
  --cyan: #61d7ff;
  --green: #75efb6;
  --red: #ff7c88;
}

* { box-sizing: border-box; }

html { min-width: 0; }

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  letter-spacing: 0;
}

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

button,
.file-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: #172231;
  color: var(--text);
  cursor: pointer;
}

button { white-space: nowrap; }

.primary {
  border: 0;
  background: linear-gradient(120deg, var(--cyan), var(--green));
  color: #041216;
  font-weight: 800;
}

.danger {
  border-color: #7a3440;
  background: #3a1820;
  color: #ffd9dd;
}

input,
select,
textarea {
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #0d1520;
  color: var(--text);
}

textarea {
  line-height: 1.45;
  resize: vertical;
  scrollbar-color: var(--line) #0d1520;
}

input::placeholder,
textarea::placeholder { color: #8997aa; }

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
  accent-color: var(--cyan);
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
}

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

h1 { font-size: 38px; }
h2 { font-size: 19px; }

.eyebrow {
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.app-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(20px, calc((100vw - 1440px) / 2));
  border-bottom: 1px solid var(--line);
  background: #090f18;
}

.brand {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 20px;
  font-weight: 900;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header nav { display: flex; gap: 20px; }
.app-header nav a { color: var(--muted); text-decoration: none; }
.app-header nav a[aria-current] { color: var(--cyan); }

.page {
  width: min(1120px, calc(100% - 32px));
  margin: 36px auto 80px;
}

.page.wide { width: min(1440px, calc(100% - 32px)); }

.page-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 24px;
}

.page-title h1 { margin: 4px 0 0; }

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--panel);
}

.profile-grid,
.work-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.work-grid { grid-template-columns: 320px 1fr; }
.controls { display: grid; gap: 16px; align-content: start; }
.controls select { width: 100%; }

.inline,
.toolbar,
.dialog-actions,
.editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline input { min-width: 0; flex: 1; }
.toolbar { flex-wrap: wrap; margin-bottom: 16px; }
.data-list { display: grid; gap: 8px; margin-top: 14px; }

.data-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.tabs { display: flex; gap: 4px; overflow: auto; margin-bottom: 14px; }
.tabs button[aria-selected="true"] { border-color: var(--cyan); color: var(--cyan); }

.canvas-wrap {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #03060a;
}

.canvas-wrap canvas { position: absolute; max-width: 100%; max-height: 100%; }
#box-canvas { touch-action: none; }
.canvas-wrap span { padding: 28px; color: var(--muted); text-align: center; }
.editor-actions { justify-content: flex-end; margin-top: 14px; }

dl { display: grid; grid-template-columns: 160px 1fr; gap: 12px; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 20%, #13243a, #070b12 55%);
}

.auth-panel { width: min(480px, 100%); text-align: center; }
.auth-panel h1 { margin: 8px 0 10px; font-size: 44px; }
.auth-panel p { color: var(--muted); line-height: 1.5; }
.auth-panel [hidden] { display: none !important; }

.qr-wrap {
  width: max-content;
  max-width: 100%;
  display: grid;
  place-items: center;
  margin: 18px auto;
  padding: 16px;
  border-radius: 8px;
  background: white;
}

.qr-wrap img { display: block; width: min(300px, 70vw); height: auto; }
.auth-secondary { width: 100%; margin-top: 4px; }
.password-login { display: grid; gap: 14px; margin-top: 8px; text-align: left; }
.password-login h1,
.password-login > p { margin-bottom: 0; text-align: center; }
.password-login input,
.password-login button { width: 100%; }
.password-login .countdown { min-height: 22px; margin: 0; text-align: center; }
.password-login .status { min-height: 48px; margin: 0; text-align: center; }
.countdown { color: var(--muted); }
button:disabled { cursor: wait; opacity: .68; }

dialog {
  width: min(520px, calc(100% - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: #101722;
  color: var(--text);
}

dialog::backdrop { background: rgba(0, 0, 0, .72); }
dialog label { margin: 16px 0; }
.icon-close { float: right; min-height: 32px; }
.status { margin-top: 14px; color: var(--muted); }
pre { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); }

@media (max-width: 800px) {
  .profile-grid,
  .work-grid { grid-template-columns: 1fr; }
  .app-header nav a:not([aria-current]) { display: none; }
  .canvas-wrap { min-height: 380px; }
  .toolbar > * { width: 100%; }
  .inline > * { width: auto; }
  dl { grid-template-columns: 1fr; }
  .page-title { align-items: start; }
}

@media (max-width: 480px) {
  .app-header { padding-inline: 12px; }
  .brand { font-size: 16px; }
  .page,
  .page.wide { width: calc(100% - 20px); }
  dialog { width: calc(100% - 16px); max-width: calc(100% - 16px); padding: 16px; }
}
