:root {
  color-scheme: light;
  --ink: #1c1b1a;
  --muted: #706d67;
  --paper: #f5f2eb;
  --paper-deep: #eae5da;
  --card: rgba(255, 255, 255, 0.78);
  --line: rgba(30, 28, 25, 0.12);
  --accent: #6754d9;
  --accent-dark: #4d3eb1;
  --accent-soft: #e8e4ff;
  --green: #2f8a63;
  --yellow: #c88118;
  --red: #bf4c58;
  --shadow: 0 24px 80px rgba(42, 37, 28, 0.12);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(39, 36, 31, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(39, 36, 31, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(103, 84, 217, 0.28);
  outline-offset: 3px;
}

.hidden { display: none !important; }

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(1px);
  pointer-events: none;
}
.ambient-one {
  width: 30rem;
  height: 30rem;
  top: -14rem;
  right: -8rem;
  background: radial-gradient(circle, rgba(127, 104, 232, 0.23), rgba(127, 104, 232, 0));
}
.ambient-two {
  width: 28rem;
  height: 28rem;
  bottom: -15rem;
  left: -8rem;
  background: radial-gradient(circle, rgba(228, 166, 87, 0.18), rgba(228, 166, 87, 0));
}

.screen { min-height: 100vh; }
.boot-screen { display: grid; place-content: center; justify-items: center; gap: 20px; }
.boot-mark {
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 22px;
  font-weight: 850;
  font-size: 25px;
  letter-spacing: -1px;
  transform: rotate(-4deg);
}
.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login-screen { display: grid; place-items: center; padding: 28px; }
.login-card {
  width: min(100%, 980px);
  min-height: 570px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(300px, 0.85fr);
  grid-template-rows: auto 1fr auto;
  gap: 36px 80px;
  padding: 54px 62px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 36px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 850; letter-spacing: 0.14em; }
.brand-login { grid-column: 1 / -1; }
.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  color: white;
  background: var(--ink);
  font-size: 12px;
  letter-spacing: 0;
}
.login-copy { align-self: center; }
.eyebrow {
  margin: 0 0 18px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.2em;
}
.login-copy h1, .hero-copy h1, .library-heading h1 {
  margin: 0;
  font-family: Georgia, "Songti SC", "SimSun", serif;
  font-weight: 500;
  letter-spacing: -0.055em;
}
.login-copy h1 { font-size: clamp(44px, 5vw, 68px); line-height: 1.06; }
.login-copy > p:last-child, .library-heading > div > p:last-child {
  max-width: 390px;
  margin: 24px 0 0;
  color: var(--muted);
  line-height: 1.8;
}
.login-form { align-self: center; display: grid; gap: 10px; }
.login-form label { margin-top: 10px; font-size: 13px; font-weight: 750; }
.login-form input {
  width: 100%;
  height: 54px;
  padding: 0 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(250, 249, 246, 0.88);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(103, 84, 217, 0.1); outline: none; }
.form-error { min-height: 20px; margin: 4px 0 0; color: var(--red); font-size: 13px; }
.login-footnote { grid-column: 1 / -1; margin: 0; color: #9b968d; font-size: 12px; text-align: right; }

.button {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-weight: 760;
  text-decoration: none;
  transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
}
.button:hover { transform: translateY(-2px); }
.button:disabled { cursor: not-allowed; opacity: 0.5; transform: none; }
.button svg, .icon-button svg, .back-button svg, .search-box svg, .select-wrap svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.button-primary { color: #fff; background: var(--accent); box-shadow: 0 12px 28px rgba(80, 62, 179, 0.22); }
.button-primary:hover { background: var(--accent-dark); box-shadow: 0 15px 34px rgba(80, 62, 179, 0.28); }
.button-secondary { border-color: var(--line); color: var(--ink); background: rgba(255, 255, 255, 0.62); }
.button-secondary:hover { background: #fff; box-shadow: 0 12px 28px rgba(40, 35, 25, 0.08); }
.button-dark { color: #fff; background: var(--ink); }
.button-wide { width: 100%; margin-top: 4px; justify-content: space-between; }

.app-shell { min-height: 100vh; }
.app-header {
  width: min(1180px, calc(100% - 48px));
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 auto;
}
.brand-button { padding: 0; border: 0; color: var(--ink); background: transparent; }
.account-area { display: flex; align-items: center; gap: 14px; }
.account-name { color: var(--muted); font-size: 13px; font-weight: 700; }
.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.5);
}
.icon-button:hover { color: var(--ink); background: white; }

.app-main { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 52px 0 120px; }
.hero-grid { display: grid; grid-template-columns: 1.5fr 0.75fr; gap: 70px; align-items: end; }
.hero-copy h1 { font-size: clamp(58px, 7.4vw, 102px); line-height: 0.96; }
.hero-copy h1 span { color: var(--accent); font-style: italic; }
.hero-description { max-width: 580px; margin: 30px 0 0; color: var(--muted); font-size: 16px; line-height: 1.8; }
.progress-card {
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 16px 48px rgba(44, 37, 28, 0.07);
  backdrop-filter: blur(16px);
}
.progress-heading { display: flex; align-items: flex-start; justify-content: space-between; color: var(--muted); font-size: 13px; font-weight: 700; }
.progress-heading strong { color: var(--ink); font-size: 34px; line-height: 1; }
.progress-heading small { margin-left: 3px; color: var(--muted); font-size: 14px; }
.progress-track { height: 7px; margin: 24px 0 16px; overflow: hidden; border-radius: 999px; background: var(--paper-deep); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #9b85f2); transition: width 0.5s ease; }
.progress-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.draw-panel {
  margin-top: 64px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(247, 244, 237, 0.58);
}
.settings-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.setting-item {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
}
.setting-item strong, .setting-item small { display: block; }
.setting-item strong { margin-bottom: 7px; font-size: 14px; }
.setting-item small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.setting-toggle { cursor: pointer; }
.setting-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.toggle { position: relative; flex: 0 0 auto; width: 48px; height: 28px; border-radius: 99px; background: #d8d3c8; transition: background 0.2s; }
.toggle::after { content: ""; position: absolute; width: 22px; height: 22px; top: 3px; left: 3px; border-radius: 50%; background: white; box-shadow: 0 2px 7px rgba(0,0,0,.18); transition: transform 0.2s; }
.setting-toggle input:checked + .toggle { background: var(--accent); }
.setting-toggle input:checked + .toggle::after { transform: translateX(20px); }
.setting-toggle input:focus-visible + .toggle { outline: 3px solid rgba(103, 84, 217, 0.28); outline-offset: 3px; }
.select-wrap { position: relative; flex: 0 0 auto; }
.select-wrap select, .filter-bar select {
  min-width: 142px;
  height: 44px;
  padding: 0 38px 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #f7f5f0;
  appearance: none;
}
.select-wrap svg { position: absolute; top: 12px; right: 11px; width: 18px; pointer-events: none; }
.settings-status { min-height: 18px; margin: 12px 2px -2px; color: var(--green); font-size: 12px; }
.action-row { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; margin-top: 24px; }
.action-row .button { min-height: 66px; border-radius: 17px; font-size: 16px; }

.result-card {
  position: relative;
  margin-top: 24px;
  padding: 38px 42px;
  overflow: hidden;
  border-radius: 28px;
  color: #fff;
  background: linear-gradient(135deg, #2c2934 0%, #19181c 76%);
  box-shadow: 0 24px 60px rgba(31, 27, 38, 0.2);
  animation: result-in 0.42s ease-out both;
}
.result-card::after { content: "100"; position: absolute; right: -10px; bottom: -56px; color: rgba(255,255,255,.035); font-family: Georgia, serif; font-size: 220px; line-height: 1; pointer-events: none; }
@keyframes result-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.result-topline { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; }
.result-label { color: #a999ff; font-size: 11px; font-weight: 850; letter-spacing: 0.2em; }
.result-completed { padding: 5px 9px; border-radius: 99px; color: #bdebd4; background: rgba(70, 168, 119, 0.18); font-size: 11px; font-weight: 750; }
.result-number { position: relative; z-index: 1; margin: 34px 0 8px; color: #9c98a5; font-family: ui-monospace, monospace; font-size: 13px; }
.result-card h2 { position: relative; z-index: 1; max-width: 720px; margin: 0 0 20px; font-family: Georgia, "Songti SC", serif; font-size: clamp(32px, 4vw, 52px); font-weight: 500; letter-spacing: -0.035em; }
.tag-row { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 8px; }
.tag { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border: 1px solid rgba(255,255,255,.13); border-radius: 99px; color: #d2ced9; font-size: 11px; }
.tag.difficulty-easy { color: #9be1bd; border-color: rgba(100, 206, 151, .28); }
.tag.difficulty-medium { color: #f0c779; border-color: rgba(230, 172, 72, .3); }
.tag.difficulty-hard { color: #f39ca6; border-color: rgba(221, 101, 114, .3); }
.result-note { position: relative; z-index: 1; min-height: 20px; margin: 18px 0 0; color: #aaa5b3; font-size: 12px; }
.result-card .button { position: relative; z-index: 1; margin-top: 24px; border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.1); }
.result-card .button:hover { background: rgba(255,255,255,.17); }

.library-heading { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 24px; }
.back-button { grid-column: 1 / -1; display: inline-flex; width: fit-content; align-items: center; gap: 6px; padding: 0; border: 0; color: var(--muted); background: transparent; font-size: 13px; }
.back-button:hover { color: var(--ink); }
.back-button svg { width: 18px; }
.library-heading h1 { font-size: clamp(48px, 6vw, 76px); }
.library-total { min-width: 150px; padding: 20px 24px; border-left: 1px solid var(--line); }
.library-total strong, .library-total span { display: block; }
.library-total strong { margin-bottom: 4px; font-family: Georgia, serif; font-size: 40px; font-weight: 500; }
.library-total span { color: var(--muted); font-size: 12px; }
.filter-bar { position: sticky; top: 12px; z-index: 5; display: grid; grid-template-columns: 1fr auto auto; gap: 10px; margin: 46px 0 30px; padding: 12px; border: 1px solid rgba(255,255,255,.8); border-radius: 18px; background: rgba(249, 247, 241, .84); box-shadow: 0 12px 36px rgba(43,36,27,.08); backdrop-filter: blur(18px); }
.search-box { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; }
.search-box svg { flex: 0 0 auto; width: 19px; color: var(--muted); }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; }
.problem-list { display: grid; gap: 28px; }
.category-section { overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.62); }
.category-header { display: flex; align-items: center; justify-content: space-between; padding: 19px 22px; border-bottom: 1px solid var(--line); }
.category-header h2 { margin: 0; font-size: 15px; }
.category-header span { color: var(--muted); font-size: 12px; }
.problem-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.problem-item { position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; min-height: 78px; padding: 14px 20px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .16s; }
.problem-item:nth-child(odd) { border-right: 1px solid var(--line); }
.problem-item:nth-last-child(-n+2) { border-bottom: 0; }
.problem-item:hover { background: rgba(103,84,217,.045); }
.problem-item input { position: absolute; opacity: 0; }
.problem-check { display: grid; width: 22px; height: 22px; place-items: center; border: 1.5px solid #bdb7ac; border-radius: 7px; color: white; transition: background .16s, border-color .16s; }
.problem-check svg { width: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; opacity: 0; }
.problem-item input:checked + .problem-check { border-color: var(--accent); background: var(--accent); }
.problem-item input:checked + .problem-check svg { opacity: 1; }
.problem-item input:focus-visible + .problem-check { outline: 3px solid rgba(103,84,217,.25); outline-offset: 3px; }
.problem-copy { min-width: 0; }
.problem-title { display: block; overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.problem-tags { display: block; overflow: hidden; margin-top: 6px; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.problem-id { color: #aaa49a; font-family: ui-monospace, monospace; font-size: 11px; }
.difficulty-dot { display: inline-block; width: 6px; height: 6px; margin: 0 5px 1px 0; border-radius: 50%; background: var(--yellow); }
.difficulty-dot.easy { background: var(--green); }
.difficulty-dot.hard { background: var(--red); }
.empty-filter { padding: 70px 20px; color: var(--muted); text-align: center; }
.save-bar { position: fixed; z-index: 10; left: 50%; bottom: 24px; width: min(700px, calc(100% - 40px)); display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px 14px 13px 22px; border: 1px solid rgba(255,255,255,.25); border-radius: 18px; color: white; background: rgba(29,27,25,.93); box-shadow: 0 18px 50px rgba(29,25,20,.28); backdrop-filter: blur(16px); transform: translateX(-50%); }
.save-bar span { color: #d1cdc7; font-size: 13px; }
.save-bar .button { min-height: 44px; }

.toast { position: fixed; z-index: 30; right: 24px; bottom: 24px; max-width: min(390px, calc(100% - 48px)); padding: 14px 18px; border-radius: 13px; color: #fff; background: rgba(29,27,25,.95); box-shadow: 0 12px 38px rgba(20,18,16,.22); font-size: 13px; line-height: 1.5; opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: #8e3540; }

@media (max-width: 820px) {
  .login-card { grid-template-columns: 1fr; gap: 26px; padding: 38px; }
  .brand-login, .login-footnote { grid-column: auto; }
  .login-footnote { text-align: left; }
  .hero-grid { grid-template-columns: 1fr; gap: 40px; }
  .settings-row { grid-template-columns: 1fr; }
  .problem-grid { grid-template-columns: 1fr; }
  .problem-item:nth-child(odd) { border-right: 0; }
  .problem-item:nth-last-child(2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 600px) {
  .login-screen { padding: 14px; }
  .login-card { min-height: calc(100vh - 28px); padding: 28px 22px; border-radius: 26px; }
  .login-copy h1 { font-size: 46px; }
  .app-header, .app-main { width: min(100% - 30px, 1180px); }
  .app-header { height: 76px; }
  .app-main { padding-top: 35px; }
  .account-name { display: none; }
  .hero-copy h1 { font-size: 58px; }
  .draw-panel { margin-top: 44px; padding: 16px; border-radius: 22px; }
  .setting-item { align-items: flex-start; padding: 16px; }
  .setting-item:not(.setting-toggle) { flex-direction: column; gap: 14px; }
  .select-wrap, .select-wrap select { width: 100%; }
  .action-row { grid-template-columns: 1fr; }
  .result-card { padding: 30px 24px; }
  .library-heading { grid-template-columns: 1fr; }
  .library-total { padding: 16px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .search-box { grid-column: 1 / -1; }
  .filter-bar select { width: 100%; min-width: 0; }
  .save-bar { bottom: 12px; }
  .save-bar span { max-width: 130px; }
  .toast { right: 15px; bottom: 15px; max-width: calc(100% - 30px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
