:root {
  color-scheme: light;
  --text: #223a32;
  --bg: #f3f5f0;
  --surface: #ffffff;
  --accent: #215c46;
  --soft: #e7ede6;
  --border: #ced8ce;
  --muted: #58695e;
  --sidebar: #e9eee5;
  --selected: #d7e3d1;
  --notice: #fff5dc;
  --notice-text: #795b20;
  --link: #356b4b;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --text: #e0eae5;
  --bg: #111a18;
  --surface: #1c2925;
  --accent: #28634e;
  --soft: #293a33;
  --border: #42574c;
  --muted: #a8bdb0;
  --sidebar: #17221e;
  --selected: #314d3e;
  --notice: #383322;
  --notice-text: #f0d69c;
  --link: #a5d7b8;
}
:root[data-theme="blue"] {
  --text: #203850;
  --bg: #f0f5fb;
  --surface: #fff;
  --accent: #235e9c;
  --soft: #e3edf8;
  --border: #bdcfe3;
  --muted: #526a82;
  --sidebar: #e6eef8;
  --selected: #cddff3;
  --link: #205f9f;
}
:root {
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 10px;
  padding: 11px 17px;
}
button:hover {
  filter: brightness(0.93);
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button.secondary {
  background: var(--soft);
  color: var(--text);
}
input,
select,
textarea {
  width: 100%;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
}
textarea {
  min-height: 100px;
  resize: vertical;
}
label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 14px 0 6px;
}
h1 {
  font-size: 30px;
  letter-spacing: -1px;
  margin: 8px 0 12px;
}
h2 {
  font-size: 20px;
  margin: 0 0 12px;
}
h3 {
  font-size: 16px;
}
p {
  line-height: 1.7;
}
small,
.muted {
  color: var(--muted);
}
.auth {
  max-width: 460px;
  margin: 8vh auto;
  padding: 30px;
}
.brand {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -1px;
}
.brand span {
  color: #739b54;
}
.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
.sidebar {
  padding: 32px 22px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.sidebar .brand {
  margin-bottom: 35px;
}
.nav {
  background: transparent;
  color: var(--muted);
  text-align: left;
}
.nav.active {
  background: var(--selected);
  color: var(--text);
  font-weight: 650;
}
.sidebar footer {
  margin-top: auto;
  padding-top: 30px;
  font-size: 12px;
  color: var(--muted);
}
.main {
  padding: 32px 5%;
  max-width: 1400px;
  width: 100%;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 35px;
  gap: 16px;
}
.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 20px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.stat {
  font-size: 32px;
  font-weight: 650;
  margin: 14px 0;
}
.row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.row > * {
  flex: 1;
  min-width: 120px;
}
.actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th,
td {
  text-align: left;
  padding: 13px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th {
  color: var(--muted);
  font-weight: 500;
}
.badge {
  display: inline-block;
  background: var(--soft);
  color: var(--text);
  padding: 5px 9px;
  border-radius: 20px;
  font-size: 12px;
}
.empty {
  padding: 34px 10px;
  color: var(--muted);
  text-align: center;
}
.message {
  padding: 16px;
  border-radius: 12px;
  margin: 12px 0;
  background: var(--soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message.user {
  background: var(--selected);
  margin-left: 10%;
}
.chatlog {
  max-height: 50vh;
  overflow: auto;
}
.prose {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.7;
}
#toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 13px 22px;
  border-radius: 12px;
  max-width: 90%;
  display: none;
  z-index: 10;
}
details {
  margin: 15px 0;
}
summary {
  cursor: pointer;
  color: var(--text);
}
pre {
  overflow: auto;
  font-size: 12px;
  white-space: pre-wrap;
}
.notice {
  background: var(--notice);
  padding: 13px;
  border-radius: 10px;
  color: var(--notice-text);
  font-size: 13px;
}
.qr {
  max-width: 260px;
  display: block;
}
a {
  color: var(--link);
}
input:focus,
button:focus-visible,
select:focus,
textarea:focus {
  outline: 2px solid #79a05e;
  outline-offset: 2px;
}
@media (max-width: 760px) {
  .shell {
    display: block;
  }
  .sidebar {
    padding: 16px;
    flex-direction: row;
    overflow-x: auto;
    align-items: center;
    gap: 5px;
  }
  .sidebar .brand {
    margin: 0 12px 0 0;
    white-space: nowrap;
  }
  .sidebar footer {
    display: none;
  }
  .nav {
    white-space: nowrap;
    padding: 10px;
  }
  .main {
    padding: 22px 16px;
  }
  .grid,
  .grid.two {
    grid-template-columns: 1fr;
  }
  .topbar {
    margin-bottom: 22px;
  }
  .card {
    padding: 18px;
  }
  .auth {
    margin: 4vh auto;
  }
  .stat {
    font-size: 28px;
  }
}
dialog {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  max-width: min(90vw, 600px);
  color: var(--text);
}
dialog::backdrop {
  background: #203b3055;
}
hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}
td {
  max-width: 300px;
  white-space: normal;
  overflow-wrap: anywhere;
}
input[type="file"] {
  padding: 14px;
}
details p {
  max-height: 400px;
  overflow: auto;
}
.actions button {
  flex: none;
}
select {
  max-width: 100%;
}

.main,
.card,
#content,
#adminbody,
.grid > *,
form {
  min-width: 0;
}
.top-actions {
  align-items: center;
  margin-top: 0;
}
.theme-control {
  margin: 0;
  min-width: 140px;
  font-size: 12px;
}
.theme-control select {
  padding: 8px;
}
.button-link {
  display: inline-flex;
  align-items: center;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
}
.saved-model {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.saved-model span {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
dialog {
  background: var(--surface);
}
#toast {
  background: var(--accent);
  color: white;
}
.qr {
  width: min(100%, 260px);
  height: auto;
}
@media (max-width: 760px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
  }
  .top-actions > * {
    min-width: 0;
    text-align: center;
  }
  .theme-control {
    text-align: left;
  }
  .sidebar {
    max-width: 100vw;
    scrollbar-width: thin;
  }
  .sidebar > * {
    flex-shrink: 0;
  }
  .row > * {
    min-width: 0;
    flex-basis: 100%;
  }
  input,
  select,
  textarea {
    font-size: 16px;
  }
  button,
  .button-link {
    min-height: 44px;
  }
  .actions {
    gap: 8px;
  }
  .actions button {
    flex: 1 1 auto;
  }
  .card {
    padding: 16px;
    border-radius: 14px;
  }
  .main {
    padding: 20px 12px;
  }
  .auth {
    padding: 20px 16px;
  }
  .chatlog {
    max-height: 48dvh;
  }
  .notice {
    overflow-wrap: anywhere;
  }
}
