:root {
  --graphite: #414249;
  --ink: #29292d;
  --accent: #593a46;
  --accent-dark: #482d38;
  --paper: #f5f1e9;
  --surface: #fffcf6;
  --side: #eee8dd;
  --muted: #665c59;
  --line: #d6ccbf;
  --control: #91847c;
  --soft: #eee2e5;
  --green: #31594a;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
h1 { font-size: clamp(2rem, 4vw, 2.65rem); line-height: 1.14; overflow-wrap: anywhere; }
h2 { font-size: 1.45rem; line-height: 1.25; }
h3 { font-size: 1.25rem; line-height: 1.3; }
p { line-height: 1.55; }
a { color: var(--accent); }
button, input, select { font: inherit; }
button, summary { cursor: pointer; }
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
:focus-visible { outline: 2px solid #996e2c; outline-offset: 3px; }
button:disabled { cursor: wait; opacity: .65; }
input:not([type="file"]) {
  width: 100%;
  min-height: 42px;
  padding: .65rem .75rem;
  border: 1px solid var(--control);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
}
input::placeholder { color: #776d66; }
label { font-size: .875rem; font-weight: 600; }
label > input { margin-top: .44rem; }
.muted { color: var(--muted); font-size: .875rem; }
.stack { display: grid; gap: .8rem; }
.primary, .secondary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .45rem;
  padding: .66rem 1rem;
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  text-decoration: none;
  font-weight: 600;
  font-size: .875rem;
}
.primary { color: white; background: var(--accent); }
.primary:hover { background: var(--accent-dark); }
.secondary { color: var(--accent); background: transparent; }
.secondary:hover { background: var(--soft); }
.text-button {
  display: inline-block;
  border: 0;
  background: transparent;
  padding: .3rem 0;
  color: var(--accent);
  font-size: .875rem;
  text-underline-offset: 4px;
}
.text-button:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  gap: 2rem;
  min-height: 70px;
  padding: .6rem 2rem;
  background: var(--graphite);
  color: var(--paper);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .8rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.22rem;
  letter-spacing: .15em;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 36px;
  border: 1px solid #bca897;
  border-radius: 3px;
  font-size: 1.48rem;
  letter-spacing: 0;
}
.topbar nav, .account { display: flex; align-items: center; gap: 1rem; }
.topbar nav a {
  color: #ede5da;
  text-decoration: none;
  padding: .6rem .15rem;
  font-size: .875rem;
}
.topbar nav a[aria-current], .topbar nav a:hover { border-bottom: 1px solid #e5cdbb; }
.topbar nav .mobile-profile { display: none; }
.account { margin-left: auto; min-width: 0; }
.account-email {
  display: block;
  color: #ece1d5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .875rem;
}
.topbar .text-button { color: var(--paper); }

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(280px, 1fr) minmax(230px, 305px);
  min-height: calc(100dvh - 70px);
}
.practices, .materials { padding: 1.65rem 1.25rem; min-width: 0; }
.practices { border-right: 1px solid var(--line); background: var(--side); }
.materials { border-left: 1px solid var(--line); }
.practices h2, .materials h2 { margin-bottom: 1.1rem; }
.new-practice summary { width: 100%; }
.new-practice[open] summary { margin-bottom: .8rem; }
.new-practice input { margin-top: -.45rem; }
.case-list { list-style: none; margin: 1.15rem 0 0; padding: 0; display: grid; gap: .35rem; }
.case-list a {
  display: grid;
  gap: .38rem;
  padding: .8rem .7rem;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--ink);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.case-list a:hover, .case-list a[aria-current] { background: var(--soft); border-color: #cbb7bd; }
.case-list strong { font-size: .925rem; }
.case-list a > span { color: var(--muted); font-size: .8rem; }
.practice { min-width: 0; background: var(--surface); }
.practice-heading {
  padding: 2rem clamp(1.3rem, 3vw, 2.6rem) 1.65rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.practice-heading .muted, .admin-header .muted { margin-bottom: .48rem; }
.practice-body { padding: 1.75rem clamp(1.3rem, 3vw, 2.6rem); }
.practice-body > h2 { margin-bottom: .95rem; }
.result-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: clamp(1.05rem, 3vw, 1.65rem);
  background: var(--paper);
  max-width: 58rem;
}
.result-card p { margin-top: .5rem; }
.result-card small { display: block; margin-top: .75rem; overflow-wrap: anywhere; }
.state-heading { display: flex; align-items: center; gap: .65rem; }
.download { margin-top: 1rem; }
.ready-mark { color: var(--green); font-weight: 700; }
.spinner {
  width: 1rem; height: 1rem;
  border: 2px solid #dac7ce;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: turn 1s linear infinite;
}
@keyframes turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.empty-workspace { min-height: 290px; display: grid; align-content: center; justify-items: center; text-align: center; gap: .75rem; }
.empty-workspace .document-mark { margin-bottom: .2rem; }
.empty-workspace p { max-width: 33ch; color: var(--muted); }
.document-mark {
  position: relative;
  display: inline-block;
  flex: none;
  width: 26px;
  height: 31px;
  border: 1px solid #957b84;
  border-radius: 3px;
}
.document-mark::after {
  content: "";
  position: absolute;
  inset: 9px 5px auto;
  height: 6px;
  border-block: 1px solid #957b84;
}
.material-card { display: flex; gap: .6rem; padding: .9rem; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.material-card strong { overflow-wrap: anywhere; font-size: .9rem; }
.material-card p { margin-top: .25rem; }
input[type="file"] { max-width: 100%; color: var(--muted); font-size: .85rem; }
input[type="file"]::file-selector-button {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--control);
  padding: .52rem .6rem;
  border-radius: 4px;
  cursor: pointer;
}
.remove-practice { width: max-content; max-width: 100%; flex-shrink: 0; position: relative; }
.remove-practice[open] form {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 1;
  width: min(250px, 75vw);
  padding: .85rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 6px 18px #41424925;
}
.remove-practice p { font-size: .875rem; }
.notice { border-left: 3px solid var(--green); padding: .7rem .85rem; background: #e5eee5; margin-bottom: 1rem; }
.notice.error { border-color: var(--accent); background: var(--soft); }

.login-body { min-height: 100dvh; display: grid; align-items: center; padding: 1.3rem; }
.login-grid {
  width: min(840px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: .95fr 1.05fr;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  box-shadow: 0 14px 45px #41424913;
}
.login-identity {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 3rem;
  min-height: 360px;
  padding: 2.25rem;
  color: var(--paper);
  background: var(--graphite);
}
.login-identity p { font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.25rem, 3vw, 1.85rem); line-height: 1.3; }
.login-form { background: var(--surface); padding: clamp(1.45rem, 5vw, 3rem); align-self: stretch; align-content: center; }
.login-form h1 { font-size: 1.8rem; margin-bottom: 1.5rem; }
.login-form .primary { margin-top: .4rem; }
.password-control { display: grid; gap: .44rem; }
.password-row { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .7rem; }
.password-row input { flex: 1 1 8rem; min-width: 0; }
.password-row button[hidden] { display: none; }

.admin { max-width: 1450px; margin-inline: auto; padding: 2rem clamp(1rem, 4vw, 3rem) 3rem; }
.admin-header { display: flex; justify-content: space-between; align-items: end; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.45rem; }
.admin-header nav { display: flex; flex-wrap: wrap; gap: 1rem; }
.admin-header nav a { font-size: .875rem; text-underline-offset: 4px; }
.cards { display: grid; gap: .8rem; grid-template-columns: repeat(4, 1fr); }
.cards > div { background: var(--graphite); color: var(--paper); padding: 1.05rem; border-radius: 6px; display: grid; gap: .42rem; align-content: start; }
.cards span, .cards small { font-size: .875rem; }
.cards strong { font-family: Georgia, serif; font-size: 1.85rem; font-weight: 400; overflow-wrap: anywhere; }
.admin-section { margin-top: 1.5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 1.1rem; }
.admin-section h2 { margin-bottom: .9rem; }
.admin-details { margin-bottom: .8rem; }
.admin-form { margin-top: .8rem; max-width: 25rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .875rem; }
th { background: var(--side); font-weight: 600; }
th, td { padding: .65rem .65rem; vertical-align: top; border-bottom: 1px solid var(--line); line-height: 1.55; }
tr:last-child td { border-bottom: 0; }
td code { font-size: .76rem; overflow-wrap: anywhere; }
.user-actions { display: flex; flex-wrap: wrap; gap: .65rem; align-items: flex-start; }
.user-reset form { margin-top: .45rem; min-width: 180px; }
.error-page { max-width: 55ch; padding: 2rem; margin: 12vh auto 0; }
.error-page p { margin-top: 1rem; }
.error-page a { margin-top: 1.15rem; }

@media (max-width: 940px) {
  .workspace { grid-template-columns: 200px minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .practices { grid-row: span 2; }
  .materials { grid-column: 2; border-left: 0; border-top: 1px solid var(--line); align-self: stretch; }
  .materials form, .material-card { max-width: 23rem; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; gap: .35rem 1rem; padding: .7rem 1rem; }
  .topbar nav { order: 3; width: 100%; }
  .topbar nav .mobile-profile { display: inline; }
  .account-email { display: none; }
  .workspace { display: block; }
  .practices { border-right: 0; border-bottom: 1px solid var(--line); }
  .case-list { max-height: 10rem; overflow-y: auto; }
  .practice-heading { flex-direction: column; }
  .remove-practice[open] form { right: auto; left: 0; }
  .login-grid { grid-template-columns: 1fr; }
  .login-identity { padding: 1.25rem; min-height: 0; gap: 1rem; }
  .login-identity br { display: none; }
}
