:root {
  --bg: #f6f7f9;
  --text: #15171a;
  --muted: #626a73;
  --line: #d9dde3;
  --panel: #ffffff;
  --accent: #1667d9;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.ghost {
  background: #eef2f7;
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--text);
  font-weight: 750;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.login {
  max-width: 520px;
  margin: 12vh auto;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.submit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.panel,
.item-card,
.detail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 20px;
}

h1,
h2,
h3 {
  margin: 0 0 12px;
  line-height: 1.2;
}

label {
  display: grid;
  gap: 6px;
  margin: 12px 0;
}

input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 28px 0 14px;
}

.search {
  display: flex;
  gap: 8px;
  width: min(520px, 100%);
}

.items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.item-card {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  padding: 10px;
  color: var(--text);
}

.item-card img,
.thumb-placeholder {
  width: 112px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  background: #e8ecf2;
}

.thumb-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.item-card h3 {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 16px;
}

.item-card p,
.status,
.empty {
  color: var(--muted);
}

.error {
  color: var(--danger);
}

.detail {
  padding: 20px;
}

.detail-head {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  align-items: start;
}

.detail-head img {
  width: 100%;
  border-radius: 8px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 24px 0 16px;
  border-bottom: 1px solid var(--line);
}

.tabs button {
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
}

.tabs button.active {
  background: #e8f0ff;
  color: var(--accent);
}

.tab {
  display: none;
}

.tab.active {
  display: block;
}

pre {
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 16px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 16px/1.6 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (max-width: 760px) {
  .topbar,
  .topbar-user,
  .library-head,
  .search {
    align-items: stretch;
    flex-direction: column;
  }

  .page {
    padding: 16px;
  }

  .submit-grid,
  .detail-head {
    grid-template-columns: 1fr;
  }

  .item-card {
    grid-template-columns: 96px 1fr;
  }

  .item-card img,
  .thumb-placeholder {
    width: 96px;
  }
}
