:root {
  color-scheme: light;
  font-family: "DM Sans", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  --paper: #f5f3ed;
  --panel: #fffdf7;
  --ink: #243229;
  --muted: #59675d;
  --line: #dadfd5;
  --accent: #24473b;
  --wash: #e7eee5;
  --error: #912f29;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--paper); line-height: 1.55; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.85rem, 3vw, 2.6rem); letter-spacing: -.06em; line-height: 1.2; }
h2 { font-size: 1.07rem; }
h3 { font-size: .94rem; }
.muted { color: var(--muted); }
p.muted { margin-top: .4rem; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }
button, input, summary, a { outline-offset: 4px; }
button:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid #446f52; }
label { display: grid; gap: .28rem; font-size: .9rem; font-weight: 620; }
input { color: var(--ink); background: var(--panel); border: 1px solid #bdc8bb; border-radius: .45rem; padding: .58rem .66rem; min-width: 0; width: 100%; }
.primary, .secondary, .quiet {
  border: 1px solid transparent; border-radius: .42rem; padding: .5rem .78rem; font-size: .86rem; font-weight: 650;
}
.primary { background: var(--accent); color: #fff; }
.secondary { background: var(--panel); color: var(--accent); border-color: #b8c8b7; }
.quiet { background: transparent; color: var(--accent); border-color: transparent; white-space: nowrap; }
button.quiet:hover, button.secondary:hover { background: var(--wash); }
a { color: var(--accent); text-underline-offset: 3px; overflow-wrap: anywhere; }
.sign-in { min-height: 100dvh; display: grid; align-content: center; justify-items: center; padding: 1rem; }
.login-paper { width: min(100%, 26rem); padding: clamp(1.4rem, 4vw, 2.6rem); background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: .7rem; box-shadow: 0 14px 50px #23372a14; }
#login-form { margin-top: 1.6rem; display: grid; gap: 1rem; }
#login-form .primary { justify-self: start; min-width: 6rem; }
.error { color: var(--error); }
.error:empty { display: none; }
.library { border-top: 5px solid var(--accent); padding: clamp(1rem, 4vw, 3.4rem) max(1rem, calc((100vw - 1150px) / 2)) 4rem; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding-bottom: 1.25rem; border-bottom: 1px solid #cdd6cb; }
.layout { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: clamp(1rem, 3.3vw, 2.7rem); margin-top: 1.6rem; }
.filters { background: #f0f2e9; border: 1px solid var(--line); border-radius: .6rem; padding: .95rem; }
#date-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: .7rem; margin-top: .7rem; }
#date-form label { min-inline-size: 0; grid-template-columns: minmax(0, 1fr); }
#date-form input[type="date"] {
  display: block;
  inline-size: 100%;
  min-inline-size: 0;
  max-inline-size: 100%;
  min-block-size: 2.75rem;
  margin: 0;
}
.form-actions { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.filter-tags { border-top: 1px solid var(--line); padding-top: .9rem; margin-top: .95rem; }
#tags, .card-tags { display: flex; flex-wrap: wrap; gap: .38rem; margin-top: .55rem; }
.tag { font: inherit; font-size: .83rem; background: var(--panel); color: var(--accent); border: 1px solid #bdcabb; border-radius: 999px; padding: .2rem .6rem; }
.tag[aria-pressed="true"] { background: var(--accent); color: white; border-color: var(--accent); }
.tag-count { font-variant-numeric: tabular-nums; padding-left: .3rem; opacity: .75; }
.timeline-header { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.ask-panel { background: var(--panel); border: 1px solid var(--line); border-radius: .6rem; margin-bottom: 1rem; padding: .9rem 1rem; }
.ask-input { display: flex; gap: .5rem; margin-top: .35rem; }
.ask-input button { flex: none; }
#ask-status:not(:empty) { margin-top: .5rem; }
#ask-results:not(:empty) { border-top: 1px solid var(--line); margin-top: .55rem; padding-top: .3rem; }
#ask-results .card-link + .card-link { border-top: 1px solid var(--line); }
#status { font-size: .9rem; margin: .45rem 0; }
#status:empty { display: none; }
.day { margin: 1rem 0 .45rem; color: var(--muted); font-size: .85rem; font-weight: 700; }
.entry { background: var(--panel); border: 1px solid var(--line); border-radius: .6rem; padding: .9rem 1rem; margin-bottom: .8rem; }
.entry-top, .source-top { display: flex; align-items: baseline; flex-wrap: wrap; gap: .35rem .68rem; }
.entry-top time, .source-top time { font-size: .79rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.meta { color: var(--muted); font-size: .81rem; }
.cards { margin-top: .65rem; display: grid; gap: .18rem; }
.card-link { width: 100%; display: block; text-align: left; background: none; color: var(--ink); border: none; border-radius: .35rem; padding: .45rem .5rem; }
.card-link:hover { background: var(--wash); }
.english { display: block; font-family: Georgia, "Hedvig Letters Serif", serif; font-size: 1.19rem; font-weight: 550; line-height: 1.35; overflow-wrap: anywhere; }
.meaning, .hint { display: block; font-size: .88rem; color: var(--muted); }
details { margin-top: .7rem; }
details > summary { cursor: pointer; width: fit-content; color: var(--accent); font-weight: 650; font-size: .86rem; }
.source { border-left: 2px solid #d9e2d5; padding: .55rem .8rem; margin: .65rem 0; }
.source-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .92rem; margin-top: .4rem; }
#load-more { margin-top: .4rem; }
dialog { color: var(--ink); width: min(calc(100% - 1.3rem), 42rem); max-height: calc(100dvh - 2rem); padding: clamp(1rem, 4vw, 1.65rem); border: 1px solid var(--line); border-radius: .7rem; background: var(--panel); }
dialog::backdrop { background: #17291f8c; }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; gap: .4rem; padding-bottom: .7rem; border-bottom: 1px solid var(--line); }
.dialog-header h2 { font-family: Georgia, "Hedvig Letters Serif", serif; font-size: 1.5rem; overflow-wrap: anywhere; }
.detail-block { margin-top: .9rem; }
.detail-block h3 { margin-bottom: .2rem; }
.detail-disclosure { border-top: 1px solid var(--line); }
.detail-disclosure > summary { width: 100%; padding: .65rem 0 .35rem; }
.tag-edit { border: 0; margin: 0; min-width: 0; padding: 0; }
.tag-form { display: flex; align-items: end; gap: .5rem; margin-top: .7rem; }
.tag-form input { width: min(12rem, 100%); }
@media (max-width: 700px) {
  .layout { grid-template-columns: 1fr; gap: 1rem; margin-top: 1rem; }
  .filters { padding: .8rem; }
  .filter-tags { margin-top: .65rem; padding-top: .6rem; }
}
@media (min-width: 481px) and (max-width: 700px) {
  #date-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #date-form .form-actions { grid-column: 1 / -1; }
}
