* {
  box-sizing: border-box;
}

:root {
  --bg: #0d1114;
  --panel: rgba(28, 32, 37, .92);
  --panel-soft: rgba(31, 35, 40, .76);
  --line: rgba(255, 255, 255, .09);
  --gold: #f2bf75;
  --gold-2: #d49b4c;
  --green: #2f9b63;
  --red: #ef5656;
  --text: #f5f1e8;
  --muted: #9ca3af;
  --shadow: 0 24px 70px rgba(0, 0, 0, .32);
}

html {
  font-size: 16px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 84% 18%, rgba(242, 191, 117, .1), transparent 28%),
    radial-gradient(circle at 20% 0%, rgba(74, 95, 111, .18), transparent 34%),
    linear-gradient(135deg, #11161b 0%, #0b0f12 55%, #090c0f 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .16), transparent 42%),
    radial-gradient(circle at 12% 78%, rgba(255, 255, 255, .04), transparent 26%);
  opacity: .9;
}

a {
  color: var(--gold);
  text-decoration: none;
  transition: color .18s ease, opacity .18s ease;
}

a:hover {
  color: #ffd89a;
}

nav {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 5;
  width: 260px;
  min-height: 100vh;
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(8, 12, 15, .82);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
  box-shadow: 16px 0 54px rgba(0, 0, 0, .28);
}

nav b {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  margin: 0 8px 22px;
  color: var(--gold);
  font-size: 23px;
  letter-spacing: .02em;
}

nav b::before {
  content: "▰";
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #0d1114;
  border-radius: 10px;
  background: linear-gradient(135deg, #ffd78f, var(--gold-2));
}

nav a {
  min-height: 52px;
  padding: 0 18px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  color: rgba(245, 241, 232, .82);
  font-weight: 650;
}

nav a:hover {
  color: var(--gold);
  background: linear-gradient(90deg, rgba(242, 191, 117, .17), rgba(242, 191, 117, .04));
}

main {
  position: relative;
  z-index: 1;
  max-width: 1260px;
  min-height: 100vh;
  margin-left: 260px;
  padding: 54px 34px 70px;
}

main::before {
  content: "";
  position: fixed;
  left: 260px;
  top: 0;
  right: 0;
  height: 84px;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 16, 20, .52);
  backdrop-filter: blur(16px);
  z-index: -1;
}

h1 {
  margin: 0 0 12px;
  color: #fffaf0;
  font-size: 30px;
  line-height: 1.25;
  letter-spacing: .01em;
}

h1::after {
  content: "管理古诗学习内容、注释、翻译和学习记录";
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 400;
}

h2 {
  margin: 0 0 10px;
  color: #fffaf0;
  font-size: 22px;
}

p {
  color: var(--muted);
  line-height: 1.75;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
  margin-top: 30px;
}

.card,
.panel,
.grid-form,
table {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .018)),
    var(--panel-soft);
  box-shadow: var(--shadow);
}

.card,
.panel {
  border-radius: 10px;
  padding: 22px;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.card:hover,
.panel:hover {
  transform: translateY(-2px);
  border-color: rgba(242, 191, 117, .34);
  box-shadow: 0 28px 78px rgba(0, 0, 0, .42);
}

.card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 1px solid rgba(242, 191, 117, .18);
  background: linear-gradient(135deg, rgba(242, 191, 117, .2), rgba(63, 125, 88, .12));
}

.fill {
  display: block;
  color: inherit;
}

.fill p,
.card p {
  margin: 6px 0 0;
}

.inline {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.panel {
  margin-top: 26px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-top: 18px;
  padding: 22px;
  border-radius: 10px;
}

.wide {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

.full {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 8px;
  color: rgba(245, 241, 232, .82);
  font-weight: 650;
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  outline: none;
  color: var(--text);
  font: inherit;
  background: rgba(8, 12, 15, .62);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(242, 191, 117, .72);
  box-shadow: 0 0 0 4px rgba(242, 191, 117, .1);
  background: rgba(8, 12, 15, .86);
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--gold);
}

input[type="file"] {
  padding: 10px;
}

textarea {
  min-height: 150px;
  line-height: 1.75;
  resize: vertical;
}

button,
.button {
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #15100b;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  background: linear-gradient(135deg, #ffd89a, var(--gold));
  box-shadow: 0 12px 28px rgba(242, 191, 117, .18);
  transition: transform .16s ease, filter .16s ease, box-shadow .16s ease;
}

button:hover,
.button:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

button:active,
.button:active {
  transform: translateY(1px) scale(.99);
}

.danger {
  color: #ff6868;
}

.notice {
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid rgba(242, 191, 117, .3);
  border-radius: 10px;
  color: #f6ddb7;
  background: rgba(242, 191, 117, .08);
  line-height: 1.7;
  word-break: break-word;
}

.notice.bad,
.bad {
  border-color: rgba(239, 86, 86, .35);
  color: #ffb0b0;
  background: rgba(239, 86, 86, .08);
}

.help {
  color: var(--muted);
}

.poem-card {
  min-height: 210px;
}

.poem-card details {
  position: relative;
  margin-top: 20px;
}

.poem-card summary {
  width: max-content;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--gold);
  cursor: pointer;
  background: rgba(255, 255, 255, .04);
}

.poem-card details[open] summary {
  border-color: rgba(242, 191, 117, .32);
}

.poem-card details a {
  display: block;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.poem-text {
  text-align: center;
  font-family: KaiTi, STKaiti, serif;
  font-size: 32px;
  line-height: 2.4;
  letter-spacing: .18em;
}

.char {
  position: relative;
  min-width: 48px;
  height: 48px;
  margin: 6px;
  padding: 0;
  border: 1px solid rgba(242, 191, 117, .22);
  border-radius: 8px;
  color: #fff3de;
  background: rgba(242, 191, 117, .08);
  font-family: KaiTi, STKaiti, serif;
  font-size: 28px;
  box-shadow: none;
}

.char:hover {
  border-color: rgba(242, 191, 117, .62);
  background: rgba(242, 191, 117, .14);
}

table {
  width: 100%;
  margin-top: 24px;
  border-collapse: collapse;
  border-radius: 10px;
  overflow: hidden;
}

th,
td {
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: rgba(245, 241, 232, .88);
  background: rgba(255, 255, 255, .035);
}

td {
  color: rgba(245, 241, 232, .74);
}

tr:hover td {
  background: rgba(255, 255, 255, .025);
}

.login {
  width: min(460px, calc(100vw - 36px));
  min-height: auto;
  margin: 18vh auto 0;
  padding: 42px 38px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .025)),
    rgba(22, 26, 31, .86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login::before {
  display: none;
}

.login h1 {
  text-align: center;
}

.login h1::after {
  content: "请输入管理密码进入后台";
  text-align: center;
}

.install-page h1::after {
  content: "自动创建数据表并设置后台管理员密码";
}

code {
  padding: 2px 6px;
  border-radius: 4px;
  color: #ffd89a;
  background: rgba(255, 255, 255, .08);
}

@media (max-width: 860px) {
  nav {
    position: sticky;
    top: 0;
    width: 100%;
    min-height: auto;
    padding: 10px 14px;
    flex-direction: row;
    overflow-x: auto;
  }

  nav b {
    flex: 0 0 auto;
    margin: 0 12px 0 0;
    font-size: 18px;
  }

  nav a {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0 14px;
  }

  main {
    margin-left: 0;
    padding: 24px 16px 52px;
  }

  main::before {
    display: none;
  }

  .cards {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .grid-form,
  .wide {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .login {
    margin: 12vh auto 0;
    padding: 28px 22px;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* Functional responsive overrides for the current admin markup. */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.nav-links form {
  margin: 0;
}

.nav-logout {
  width: 100%;
  justify-content: flex-start;
  padding: 0 18px;
  color: rgba(245, 241, 232, .82);
  background: transparent;
  box-shadow: none;
}

body > main:not(.login) {
  width: calc(100% - 260px);
  max-width: none;
  overflow: hidden;
}

.card,
.panel,
.grid-form,
.inline,
.translation-item,
.ai-field,
input,
textarea,
select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.secondary {
  color: var(--gold);
  border: 1px solid rgba(242, 191, 117, .35);
  background: rgba(242, 191, 117, .07);
  box-shadow: none;
}

.danger-button {
  color: #ff9898;
  border: 1px solid rgba(239, 86, 86, .35);
  background: rgba(239, 86, 86, .08);
  box-shadow: none;
}

.delete-form {
  margin-top: 12px;
}

.delete-form.compact {
  margin: 0;
}

.delete-form.compact button {
  min-height: 36px;
  padding: 0 12px;
}

.toolbar,
.form-actions,
.field-head,
.row-between,
.stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar {
  margin: 18px 0;
}

.stats,
.status-grid {
  margin-top: 12px;
}

.status-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
}

.status.on {
  color: #72d59d;
  background: rgba(47, 155, 99, .12);
}

.status.off {
  color: #a6adb6;
  background: rgba(255, 255, 255, .06);
}

.toggle {
  grid-template-columns: auto auto 1fr;
  align-items: center;
}

.toggle em {
  color: var(--muted);
  font-style: normal;
  font-weight: 500;
}

.cover-preview,
.file-preview {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 8px;
}

.file-preview {
  display: none;
}

.cover-placeholder,
.empty {
  padding: 32px 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.ai-field {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.ai-field textarea {
  margin-top: 12px;
}

.char.annotated {
  border-color: var(--gold);
  color: var(--gold);
}

.char sup {
  position: absolute;
  top: -8px;
  right: -5px;
  min-width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #15100b;
  background: var(--gold);
  font: 12px/1 sans-serif;
  letter-spacing: 0;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 860px) {
  nav {
    display: block;
    overflow: hidden;
  }

  .nav-links {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-links form,
  .nav-links a {
    flex: 0 0 auto;
  }

  body > main:not(.login) {
    width: 100%;
    margin-left: 0;
    padding: 24px 16px calc(96px + env(safe-area-inset-bottom));
  }

  h1 {
    font-size: 26px;
    overflow-wrap: anywhere;
  }

  .card,
  .panel,
  .grid-form {
    padding: 16px;
  }

  .toolbar .button,
  .form-actions > *,
  .field-head button {
    width: 100%;
  }

  .poem-text {
    padding: 14px 8px;
    font-size: 26px;
    letter-spacing: .08em;
  }

  .table-wrap table {
    white-space: nowrap;
  }
}

@media (max-width: 420px) {
  body > main:not(.login) {
    padding-left: 12px;
    padding-right: 12px;
  }

  .cards {
    grid-template-columns: minmax(0, 1fr);
  }

  button,
  .button {
    max-width: 100%;
    white-space: normal;
    text-align: center;
  }
}
