:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #172235;
  background: #f3f5fa;
  --blue: #194df5;
  --blue-dark: #153fc7;
  --muted: #526177;
  --border: #dce3ee;
  --surface: #fff;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

body {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  min-height: 100vh;
  margin: 0;
}

.sidebar {
  background: #f8f9fc;
  border-right: 1px solid var(--border);
  padding: 24px 14px;
}

.brand { display: flex; align-items: center; gap: 7px; padding-inline: 5px; font-size: 17px; font-weight: 750; white-space: nowrap; }
.brand img { flex: none; object-fit: contain; }
.navigation { display: grid; gap: 6px; margin-top: 32px; }
.navigation a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 14px; border-radius: 8px; color: var(--muted); font-size: 15px; font-weight: 650; }
.navigation a img { width: 22px; height: 22px; object-fit: contain; filter: grayscale(1); }
.navigation a:hover, .navigation a[aria-current] { color: var(--blue-dark); background: #e5ebfc; }
.navigation a[aria-current] img { filter: none; }

.workspace {
  width: min(100%, 1460px);
  min-width: 0;
  margin-inline: auto;
  padding: 27px clamp(18px, 2.6vw, 40px) 36px;
}

.page-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  margin-bottom: 21px;
}

h1 { margin: 0; font-size: clamp(25px, 3vw, 34px); line-height: 1.18; letter-spacing: -.025em; font-weight: 800; }
.toolbar { display: flex; justify-content: end; gap: 10px; min-width: 0; }
.toolbar input { width: min(100%, 320px); min-width: 0; min-height: 42px; padding: 8px 11px; border: 1px solid #bac5d6; border-radius: 8px; background: var(--surface); color: inherit; font-size: 15px; }
.toolbar input::placeholder { color: var(--muted); }

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 40px;
  padding: 7px 13px;
  border: 1px solid #9aaff1;
  border-radius: 8px;
  color: var(--blue-dark);
  background: var(--surface);
  font-size: 14px;
  font-weight: 650;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
}

.button:hover { background: #edf2ff; border-color: var(--blue); }
.button.primary { min-height: 42px; padding-inline: 16px; border-color: var(--blue); background: var(--blue); color: #fff; }
.button.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.button:disabled { opacity: .55; cursor: default; }

.library-list { border-top: 1px solid var(--border); }
.list-count { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.library-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 16px; width: 100%; min-height: 82px; padding: 12px 8px; border: 0; border-bottom: 1px solid var(--border); background: transparent; text-align: left; color: inherit; cursor: pointer; }
.library-row:hover { background: #eaf0fd; }
.library-row img { width: 56px; height: 56px; object-fit: contain; border-radius: 7px; background: #e8edf5; }
.library-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 600; }
.library-count { color: var(--muted); font-size: 13px; white-space: nowrap; }
dialog { width: min(940px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 20px; border: 1px solid var(--border); border-radius: 12px; background: #fff; color: inherit; }
dialog::backdrop { background: #17223599; }
.dialog-header { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.dialog-header h2 { margin: 0; font-size: 19px; overflow-wrap: anywhere; }
#library-state { color: var(--muted); font-size: 13px; margin: 8px 0 14px; }
.library-view { display: grid; grid-template-columns: minmax(0,1fr) 112px; gap: 14px; }
.library-image { display: grid; place-items: center; min-height: 100px; background: #eef1f6; border-radius: 8px; }
.library-image img { display: block; max-width: 100%; max-height: 61dvh; object-fit: contain; }
.library-thumbnails { display: grid; align-content: start; grid-template-columns: 1fr 1fr; gap: 6px; max-height: 61dvh; overflow: auto; }
.library-thumbnails button { border: 2px solid transparent; border-radius: 6px; padding: 2px; background: #eef1f6; cursor: pointer; }
.library-thumbnails button[aria-pressed=true] { border-color: var(--blue); }
.library-thumbnails img { width: 100%; height: 52px; object-fit: contain; display: block; }
.dialog-footer { display: flex; justify-content: end; gap: 10px; margin-top: 16px; }
.announcement { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.state-panel { display: grid; place-items: start; gap: 12px; min-height: 190px; align-content: center; padding: 25px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.state-panel h2, .state-panel p { margin: 0; }
.state-panel p { color: var(--muted); }
.pagination { display: flex; align-items: center; justify-content: end; gap: 12px; margin-top: 17px; color: var(--muted); font-size: 14px; }

@media (max-width: 850px) {
  body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 8px 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .navigation { display: flex; gap: 4px; margin: 0; }
  .navigation a { padding-inline: 10px; }
  .workspace { padding-top: 20px; }
}

@media (max-width: 560px) {
  .sidebar { padding-inline: 10px; }
  .brand { gap: 4px; padding-inline: 0; font-size: 15px; }
  .brand img { width: 24px; height: 27px; }
  .navigation a { gap: 4px; padding-inline: 7px; }
  .navigation a img { width: 18px; height: 18px; }
  .workspace { padding-inline: 12px; }
  .page-header { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-bottom: 14px; }
  .toolbar { grid-row: 2; grid-column: 1 / -1; }
  .library-view { grid-template-columns: 1fr; }
  .library-thumbnails { grid-template-columns: repeat(6, 1fr); max-height: 100px; }
  .toolbar input { width: 100%; }
}

.library-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.library-tabs button { border: 0; border-bottom: 3px solid transparent; padding: 12px 16px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; }
.library-tabs button[aria-selected=true] { color: var(--blue); border-bottom-color: var(--blue); }
.account-tools { display: grid; gap: 10px; padding: 24px 8px 0; margin-top: 28px; border-top: 1px solid #dce3ee; font-size: 13px; color: #526177; }
.account-tools p { margin: 0; }
.account-tools button { border: 0; background: transparent; color: inherit; padding: 0; text-align: start; cursor: pointer; }
.account-tools a:hover, .account-tools button:hover { color: #194df5; }
.login-page { display: grid; grid-template-columns: 1fr; place-items: center; padding: 20px; }
.login-panel { width: min(380px,100%); padding: 30px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.login-panel h1 { margin: 15px 0 24px; font-size: 23px; }
.account-form, .login-panel form { display: grid; gap: 15px; }
.account-form label, .login-panel label { display: grid; gap: 7px; font-size: 14px; }
.account-form input, .account-form select, .login-panel input { width: 100%; min-height: 40px; padding: 8px; border: 1px solid #bac5d6; border-radius: 7px; font: inherit; }
.login-panel .muted { color: var(--muted); font-size: 13px; }
#login-error { margin: 0; color: #a33d25; font-size: 14px; }
.account-section { margin: 24px 0; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.account-section summary { cursor: pointer; font-weight: 600; }
.account-section form { margin-top: 16px; max-width: 480px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; border-bottom: 1px solid var(--border); padding: 12px 8px; white-space: nowrap; }
td .button { margin: 3px; }
@media(max-width:850px) { .account-tools { display: none; } }
@media(max-width:850px) {
  .sidebar { flex-wrap: wrap; }
  .account-tools { display: flex; flex-wrap: wrap; align-items: center; width: 100%; gap: 10px 16px; padding: 8px 0 0; margin: 0; border: 0; font-size: 12px; }
}
