:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --panel: #ffffff;
  --ink: #1f252b;
  --muted: #68737f;
  --line: #d7dde3;
  --line-strong: #c3ccd4;
  --accent: #146c63;
  --accent-dark: #0e544d;
  --accent-soft: #e7f3f1;
  --danger: #a13737;
  --danger-soft: #fae8e8;
  --nav: #18222b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 8px 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button.danger {
  background: var(--danger-soft);
  border-color: #e2adad;
  color: var(--danger);
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 330px;
  resize: vertical;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.sidebar {
  min-height: 100vh;
  padding: 20px 14px;
  background: var(--nav);
  color: #f5f8fa;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: grid;
  gap: 10px;
}

.brand h1 {
  font-size: 22px;
  font-weight: 760;
}

#auth-state {
  width: fit-content;
  border: 1px solid #5b6872;
  border-radius: 999px;
  padding: 4px 9px;
  color: #bdc8d1;
  font-size: 12px;
}

#auth-state.ok {
  color: #c7f3d8;
  border-color: #39795a;
}

nav {
  display: grid;
  gap: 6px;
}

nav button {
  text-align: left;
  border-color: transparent;
  background: transparent;
  color: #d7e0e7;
}

nav button.active,
nav button:hover {
  background: #263540;
  color: #fff;
}

main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.topbar {
  min-height: 72px;
  padding: 14px 20px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(320px, 520px);
  gap: 18px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.topbar h2 {
  font-size: 22px;
}

.topbar p,
.detail-head p {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.top-actions,
.auth-strip,
.form-actions,
.detail-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.auth-strip {
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: #fdfefe;
}

.auth-strip input {
  max-width: 520px;
}

#save-token,
#refresh,
#save-item,
#token-form button,
#upload-form button[type="submit"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#save-token:hover,
#refresh:hover,
#save-item:hover,
#token-form button:hover,
#upload-form button[type="submit"]:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.workspace {
  min-height: 0;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: minmax(300px, 410px) minmax(0, 1fr);
  gap: 18px;
}

.list-panel,
.detail-panel {
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.list-panel {
  overflow: hidden;
}

.list {
  height: 100%;
  overflow: auto;
}

.empty {
  padding: 22px;
  color: var(--muted);
}

.row {
  width: 100%;
  display: grid;
  gap: 5px;
  padding: 13px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.row strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.row span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row:hover,
.row.selected {
  background: var(--accent-soft);
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.row-meta b,
.row-meta em {
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-style: normal;
  font-weight: 650;
}

.row-meta b {
  background: #eef0f3;
  color: #3f4952;
}

.row-meta em {
  background: #edf7f5;
  color: var(--accent-dark);
}

.detail-panel {
  overflow: auto;
}

.detail-head {
  min-height: 74px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.detail-head h3 {
  font-size: 18px;
}

.form-grid {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
}

.form-grid label span {
  color: #46515c;
  font-size: 12px;
  font-weight: 700;
}

.form-grid .wide,
.form-actions {
  grid-column: 1 / -1;
}

.form-actions {
  justify-content: flex-end;
}

.message {
  min-height: 92px;
  margin: 0 14px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  overflow: auto;
  color: var(--muted);
  background: #fafbfc;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.message.success {
  border-color: #b9d9d3;
  background: #f2faf8;
  color: #275d55;
}

.message.error {
  border-color: #e4b5b5;
  background: #fff7f7;
  color: var(--danger);
}

@media (max-width: 940px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .topbar,
  .workspace,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .top-actions,
  .auth-strip {
    flex-wrap: wrap;
  }

  .workspace {
    min-height: auto;
  }
}
