:root {
  color-scheme: light dark;
  --bg: #f7f6f0;
  --card: #fffef9;
  --ink: #202e29;
  --green: #194f40;
  --muted: #57675e;
  --line: #d4d9ce;
  --gold: #d5bf8f;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.7 "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}
header,
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px max(5vw, calc((100vw - 1080px) / 2));
  border-bottom: 1px solid var(--line);
  gap: 20px;
}
header {
  background: var(--card);
}
a {
  color: var(--green);
  text-underline-offset: 4px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font: bold 26px serif;
  white-space: nowrap;
}
.brand i {
  background: #234f40;
  color: #fff9e8;
  border-radius: 6px;
  padding: 7px;
  font: 23px serif;
}
nav {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}
nav a {
  padding: 10px 0;
  text-decoration: none;
  font-size: 14px;
}
nav a[aria-current] {
  box-shadow: inset 0 -2px var(--green);
  font-weight: bold;
}
main {
  max-width: 1120px;
  margin: 36px auto;
  padding: 0 20px;
  min-height: 69vh;
}
h1,
h2,
h3,
strong {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
}
h1 {
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1.25;
  margin: 16px 0;
}
h2 {
  font-size: 26px;
  margin: 25px 0 12px;
}
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: #193e34;
  color: #faf7e8;
  border-radius: 14px;
  padding: 40px clamp(22px, 5vw, 64px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 25px;
}
.hero h1 {
  font-size: clamp(42px, 6vw, 76px);
  letter-spacing: 0.06em;
  margin: 8px 0;
}
.hero p {
  margin: 8px 0 22px;
}
.hero small {
  color: #dfcca2;
}
.books {
  display: flex;
  align-items: flex-end;
  transform: rotate(8deg);
  gap: 5px;
  padding: 16px 20px;
  user-select: none;
}
.books i {
  writing-mode: vertical-rl;
  text-align: center;
  letter-spacing: 0.35em;
  color: #e5d6ae;
  background: #723d36;
  height: 162px;
  width: 52px;
  font: 24px serif;
  border: 4px double #c4a779;
  border-radius: 4px;
  box-shadow: 5px 6px 0 #112f29;
  padding: 10px;
}
.books i:nth-child(2) {
  background: #334d62;
  height: 184px;
}
.books i:last-child {
  background: #68653c;
  height: 202px;
}
.search {
  display: flex;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  max-width: 590px;
}
.search span {
  color: var(--muted);
  font-size: 26px;
  padding: 0 8px;
}
.search input {
  border: 0;
  min-width: 0;
  flex: 1;
}
.search button {
  background: #285447;
  color: white;
}
.tools,
.sectionTitle,
.sheetbar,
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.sectionTitle,
.row,
.sheetbar {
  justify-content: space-between;
}
.sectionTitle a,
.crumb,
small,
.meta,
aside {
  font-size: 13px;
}
.meta,
small,
aside,
.empty {
  color: var(--muted);
}
.tools {
  margin: 16px 0;
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.tile,
.paper,
.row,
.empty,
details {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
}
.tile {
  display: flex;
  align-items: center;
  gap: 18px;
  text-decoration: none;
  color: var(--ink);
}
.tile i {
  background: #dae7dc;
  color: #315e49;
  font: 30px serif;
  border-radius: 5px;
  padding: 12px;
}
.tone1 i {
  background: #e8dddd;
  color: #774f49;
}
.tone2 i {
  background: #dae1ea;
  color: #4a5972;
}
.tone3 i {
  background: #e8e4d4;
  color: #716744;
}
.tile span {
  flex: 1;
}
.tile strong,
.tile em,
.row small {
  display: block;
}
.tile strong {
  font-size: 23px;
}
.tile em {
  font: 12px sans-serif;
  color: var(--muted);
}
.row {
  padding: 14px 18px;
  margin: 6px 0;
  text-decoration: none;
}
.row:hover,
.tile:hover {
  border-color: var(--green);
}
input,
select,
textarea,
button {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  min-height: 44px;
}
button,
summary {
  cursor: pointer;
}
.paper {
  max-width: 860px;
  margin: auto;
  padding: clamp(16px, 4vw, 48px);
}
.paper h2 {
  font-size: 22px;
}
.bodytext {
  font: 20px/2 "Hiragino Mincho ProN", serif;
  white-space: pre-wrap;
}
.citation {
  border: none;
  border-radius: 0;
  min-height: 0;
  padding: 0;
  color: var(--green);
  text-decoration: underline;
  font: inherit;
}
.paper aside {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
dialog {
  background: var(--bg);
  color: var(--ink);
  border: 0;
  border-radius: 14px;
  padding: 18px;
  width: min(800px, 96vw);
  max-height: 90dvh;
  overflow: auto;
}
dialog::backdrop {
  background: #10271dc4;
}
.sheetbar {
  margin-bottom: 12px;
}
.editor label,
textarea {
  display: block;
  width: 100%;
}
img {
  max-width: 100%;
}
footer {
  font-family: serif;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  margin-top: 50px;
}
footer span {
  font: 12px sans-serif;
}
:focus-visible {
  outline: 3px solid #b58632;
  outline-offset: 3px;
}
@media (max-width: 680px) {
  header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0;
    padding: 12px 20px 0;
  }
  nav {
    width: 100%;
    justify-content: space-between;
    gap: 4px;
  }
  .books {
    display: none;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  main {
    margin: 20px auto;
  }
  .hero {
    padding: 24px 18px;
  }
  .hero p {
    font-size: 14px;
  }
  .hero > div:first-child {
    width: 100%;
  }
  .row {
    gap: 5px;
  }
  .tile {
    padding: 14px;
  }
  dialog {
    margin: auto auto 0;
    width: 100vw;
    max-width: 100vw;
    min-height: 85dvh;
    border-radius: 16px 16px 0 0;
  }
  .sheetbar {
    gap: 3px;
  }
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17231e;
    --card: #21312a;
    --ink: #f2f1df;
    --green: #b7d9c0;
    --muted: #bbcabf;
    --line: #435449;
  }
  .hero {
    background: #244b40;
  }
}

.tag-pair{display:inline-flex;align-items:center;gap:.45rem;margin:.2rem .7rem .2rem 0}.tag-pair button{min-height:32px;padding:.15rem .55rem}

.case-trigger{width:100%;text-align:left;color:inherit;background:white;cursor:pointer;font:inherit}
.case-preview{box-sizing:border-box;width:min(92vw,760px);max-height:88vh;overflow:auto;border:0;border-radius:12px;padding:clamp(16px,3vw,32px);color:#193e34}
.case-preview::backdrop{background:rgba(18,34,29,.65)}
.case-preview header{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;position:static}
.case-preview header button{flex-shrink:0}
.case-preview img{display:block;width:100%;height:auto;margin:1rem 0}
.case-trigger,.case-preview{background:var(--card);color:var(--ink);overflow-wrap:anywhere}
@media(max-width:680px){
.case-preview{width:100%;max-height:94dvh;min-height:0;margin:auto auto 0;border-radius:16px 16px 0 0;padding:0 16px max(20px,env(safe-area-inset-bottom));overscroll-behavior:contain}
.case-preview header{position:sticky;top:0;background:var(--card);flex-direction:row;align-items:center;padding:12px 0;gap:8px}
.case-preview header h2{font-size:1.1rem;margin:0}
.case-preview>button{width:100%}
.tag-pair button,nav a{min-height:44px}
}
.paragraph-label,.item-label{display:inline-block;font:600 .9rem/1.5 sans-serif;color:var(--green);border:1px solid var(--line);border-radius:.4rem;padding:.15rem .5rem;margin:.5rem .7rem .3rem 0}
.selected-paragraph{border-inline-start:4px solid var(--green);padding-inline-start:.7rem}
dialog[data-stacked=true]{box-shadow:0 -6px 0 -1px #aac2b6,0 -12px 0 -2px #789486}

.app-update-notice{position:fixed;z-index:10000;bottom:calc(80px + env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);width:max-content;max-width:calc(100% - 24px);display:flex;align-items:center;gap:12px;padding:12px 16px;background:#193e34;color:#fff;border-radius:12px;box-shadow:0 4px 24px #0003;font-size:14px}
.app-update-notice button{flex-shrink:0;background:#fff;color:#193e34;border:0;border-radius:8px;padding:10px 14px;font:inherit;font-weight:700;cursor:pointer}
