:root {
  color-scheme: light;
  --bg: #f7f5f1;
  --paper: #fffefd;
  --ink: #232126;
  --muted: #635d66;
  --line: #e4dfdc;
  --accent: #84375e;
  --accent-strong: #6d254a;
  --wash: #f8eaf1;
  --dark: #211722;
  --warn: #704410;
  --radius: 19px;
  font-family: "DM Sans", "Yu Gothic UI", "Hiragino Sans", "Meiryo", system-ui, sans-serif;
  font-size: 100%;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
[hidden] { display: none !important; }
a { color: var(--accent-strong); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button, .button, input:not([type="checkbox"], [type="radio"]), select { min-height: 44px; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border: 1px solid var(--line); border-radius: 11px; background: var(--paper);
  color: var(--ink); padding: .5rem .86rem; font-weight: 700; text-align: center;
  text-decoration: none; overflow-wrap: anywhere;
}
button:hover, .button:hover { border-color: #b58ba0; background: #fbf2f6; }
button:disabled:hover { border-color: var(--line); background: var(--paper); }
:focus-visible { outline: 3px solid #ae4b7d; outline-offset: 3px; }
h1, h2, h3, h4, p { margin: 0; overflow-wrap: anywhere; }
h2, h3, h4 { line-height: 1.35; }
h2 { font-size: clamp(1.25rem, 2.6vw, 1.55rem); letter-spacing: .012em; }
h3 { font-size: 1.04rem; }
small, .hint { font-size: .86rem; color: var(--muted); }
textarea, input:not([type="checkbox"], [type="radio"]), select {
  max-width: 100%; min-width: 0; padding: .52rem .65rem;
  border: 1px solid #d8d1d5; border-radius: 9px; background: white; color: var(--ink);
}
select { text-overflow: ellipsis; }
textarea { width: 100%; resize: vertical; min-height: 96px; display: block; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 1.05em; height: 1.05em; flex: none; }
legend { padding: 0; font-weight: 750; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.frame { width: min(100% - 28px, 1184px); margin-inline: auto; }
.site-header { background: #fffdfb; border-bottom: 1px solid var(--line); }
.header-inner { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; padding-block: .4rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; text-decoration: none; color: var(--ink); font-weight: 850; min-height: 44px; }
.app-version { padding: .08rem .4rem; border: 1px solid #ded4e9; border-radius: 6px; color: #62458a; font-size: .75rem; white-space: nowrap; }
.brand-mark { width: 35px; height: 34px; display: grid; place-items: center; background: var(--accent); border-radius: 10px; flex: none; box-shadow: 0 3px 6px #70244730; }
.brand-mark i { width: 17px; height: 13px; border: 1px solid #fff; border-radius: 3px; display: grid; place-items: center; }
.brand-mark i::after { content: ''; width: 0; height: 0; border-top: 3px solid transparent; border-bottom: 3px solid transparent; border-left: 5px solid #fff; }
.utility { display: flex; flex-wrap: wrap; gap: .25rem; }
.utility button { background: transparent; border-color: transparent; font-size: .84rem; padding-inline: .5rem; }
.utility button:hover { background: var(--wash); }
.utility #nav-manual { font-size: 1rem; gap: .35rem; }
.utility #nav-manual svg { flex: none; color: var(--accent-strong); }
#workspace { padding-block: 18px 42px; }
.hero { min-height: 165px; position: relative; display: flex; align-items: center; isolation: isolate; overflow: hidden; border-radius: 21px; background: #221522; color: #fff7fd; }
.hero-content { position: relative; padding: clamp(1.1rem, 4vw, 2.7rem); z-index: 1; }
.hero h1 { font-size: clamp(1.62rem, 4.5vw, 3.4rem); line-height: 1.15; letter-spacing: .015em; font-weight: 860; }
.hero p { color: #f1dae8; font-size: clamp(.84rem, 1.7vw, 1.09rem); margin-top: .62rem; }
.hero-art, .glow, .film-lines { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.hero-art { background: radial-gradient(ellipse at 80% 30%, #79354e 0%, #42253e 39%, #251724 72%); }
.lens { position: absolute; left: 71%; top: -77%; width: clamp(340px, 49vw, 540px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 42% 44%, #1a1423 3%, #462943 13%, #ce6583 19%, #412b55 23%, #0f1221 26%, #7e4d77 31%, #231f36 35%, #2a1640 40%, #b87991 41%, #3b233b 44%, #1c1727 54%, #6d5065 55%, #201926 57%, #282034 63%, #69495e 64%, #231922 67%);
  box-shadow: -14px 12px 40px #20132180, inset 0 0 0 2px #d9a5b33b; transform: translateX(-34%) skewX(-7deg);
  opacity: .72;
}
.glow { background: linear-gradient(90deg, #261926 8%, #261926ef 29%, #2f1a2e5e 53%, transparent 75%), linear-gradient(160deg, transparent 50%, #e091a22b 52%, transparent 59%); }
.film-lines { z-index: 0; opacity: .3; background: repeating-linear-gradient(0deg, transparent 0 3px, #fbe3ff13 4px 5px); mask-image: linear-gradient(90deg, transparent, black 69%); }
.main-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-block: 15px 18px; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: #efeae6; }
.main-tabs button { border-color: transparent; background: transparent; color: #534b54; }
.main-tabs button[aria-current="page"] { border-color: var(--line); background: var(--paper); color: var(--accent-strong); box-shadow: 0 2px 4px #463a3f0b; }
.tab-icon { display: inline-flex; align-items: center; font-size: 1.45rem; line-height: .8; }
.tab-icon.sparkle { font-size: 1.1rem; }
.tab-icon.records-icon, .search-subtabs { display: none; }
.view, .stack { display: grid; gap: 14px; min-width: 0; }
.search-grid { display: grid; gap: 15px; align-items: start; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; padding: clamp(.95rem, 2.4vw, 1.55rem); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: .65rem; }
.group { display: grid; gap: 8px; padding-block: .8rem; border-top: 1px solid #eee9e6; }
.group:first-child { border-top: 0; }
.group > legend { float: left; width: 100%; }
.fixed-search { margin-block: .8rem; padding: .8rem .85rem 0; border: 1px solid #e6ddeb; border-radius: 12px; background: #f8f4fa; }
.fixed-search > h3 { color: #5c406f; }
.fixed-search > .hint { margin-top: .25rem; }
.fixed-search > .group:first-of-type { border-top: 0; }
.condition-chip { justify-content: start; text-align: start; }
.chips, .row, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; min-width: 0; }
.row { gap: .65rem; }
.actions { gap: 8px; }
.chip { font-size: .9rem; font-weight: 650; border-radius: 9px; padding: .42rem .8rem; }
.chip[aria-pressed="true"] { color: var(--accent-strong); background: var(--wash); border-color: #d9a5bf; box-shadow: inset 0 0 0 1px #e9c4d7; }
.chip[aria-pressed="true"]::before { content: '✓'; font-size: .87em; font-weight: 850; }
.vocabulary { border-top: 1px solid #eee9e6; }
.vocabulary .group > select { justify-self: start; }
.vocabulary-chip[aria-pressed="true"] { color: #921f36; background: #fde6ea; border-color: #d88b9a; }
.gacha-condition-chip { color: var(--accent-strong); background: var(--wash); border-color: #d9a5bf; }
.gacha-condition-chip::before { content: '✓'; font-weight: 850; }
.ai-guidance { line-height: 1.7; }
summary { cursor: pointer; min-height: 44px; padding-block: .6rem; font-weight: 750; }
summary::marker { color: var(--accent); }
.details { border: 1px solid var(--line); border-radius: 12px; padding: .15rem .8rem; min-width: 0; }
.detail-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 235px), 1fr)); padding-bottom: .7rem; }
.detail-field { display: grid; gap: .45rem; align-content: start; min-width: 0; }
.detail-field label, label.field { display: grid; gap: .3rem; min-width: 0; }
.detail-field .chips { gap: .4rem; }
.range { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: .4rem; }
.range > span { padding-bottom: 10px; }
.primary { background: var(--accent); color: white; border-color: var(--accent); }
.primary:hover { background: var(--accent-strong); color: #fff; }
.primary:disabled:hover { background: var(--accent); border-color: var(--accent); }
.text-button { border-color: transparent; color: var(--accent-strong); }
.danger { color: #8b2424; border-color: #e3b2b0; }
.danger:hover { background: #fff0ed; border-color: #c06c6b; }
.full { width: 100%; }
.ai-panel { background: #fffafc; border-color: #e1ced8; display: grid; gap: 12px; }
.ai-label { display: inline-flex; align-items: center; gap: .55rem; }
.ai-label::before { content: '✦'; color: var(--accent); }
.ai-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ai-actions button { padding-inline: .4rem; }
.ai-empty { min-height: 104px; display: grid; align-content: center; gap: .2rem; padding: 13px; background: #f8f0f4; border-radius: 12px; border: 1px dashed #e1cbd7; }
.prompt-box { min-height: 190px; font-size: .88rem; line-height: 1.6; }
.notice, .warning { border-radius: 10px; padding: .65rem .85rem; }
.notice { background: #f4e6ee; color: #60334c; border: 1px solid #e4ccda; }
.warning { background: #fff4df; color: var(--warn); border: 1px solid #e8ce9f; overflow-wrap: anywhere; }
#notice, #storage-notice { margin-bottom: 12px; }
.inline-choice { display: flex; min-height: 44px; align-items: center; gap: .55rem; cursor: pointer; overflow-wrap: anywhere; }
.stats { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
.stat { background: #f5f0f3; border: 1px solid #ece3e9; padding: .58rem; border-radius: 10px; display: grid; gap: .25rem; overflow-wrap: anywhere; }
.stat strong { font-size: clamp(1rem, 4vw, 1.5rem); font-variant-numeric: tabular-nums; }
.stat > span { font-size: .79rem; color: var(--muted); }
.cards { display: grid; gap: 13px; }
.card { display: grid; align-content: start; gap: .66rem; background: #fffdfb; border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 14px; min-width: 0; padding: 13px; scroll-margin: 16px; }
.card h3 { font-size: 1.15rem; }
.card .tag { background: var(--wash); color: var(--accent-strong); padding: .18rem .48rem; border-radius: 5px; font-size: .8rem; font-weight: 700; }
.empty { border: 1px dashed #d9c9d2; border-radius: 14px; color: var(--muted); background: #f4efef; min-height: 95px; align-content: center; }
.card dl, .summary-list { margin: 0; display: grid; gap: .28rem; }
.card dl > div { display: grid; gap: .1rem .65rem; grid-template-columns: minmax(0, 6.5rem) minmax(0, 1fr); border-top: 1px solid #efe8e8; padding-top: .3rem; font-size: .88rem; }
.card dt { color: var(--muted); }
.card dd { margin: 0; overflow-wrap: anywhere; }
.card-bar, .list-item { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.card-bar .actions button { font-size: .83rem; }
.fresh { color: #7c2852; font-size: .73rem; font-weight: 850; letter-spacing: .04em; }
.list { display: grid; gap: .45rem; }
.list-item { border: 1px solid var(--line); border-radius: 10px; padding: .55rem .65rem; }
.list-item > div { min-width: 0; overflow-wrap: anywhere; }
.list-item .actions { flex: 0 1 auto; }
.list-item button { font-size: .87rem; }
.preview-diff { display: grid; gap: .45rem; padding: .65rem; background: #f8f4f6; border-radius: 10px; overflow-wrap: anywhere; }
.filterbar { display: flex; gap: .5rem; flex-wrap: wrap; }
.filterbar > * { flex: 1 1 9rem; }
.presets-grid { display: grid; gap: .55rem; }
.divider { border-top: 1px solid var(--line); padding-top: 12px; }
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; border-top: 1px solid var(--line); padding-block: 13px 25px; color: var(--muted); font-size: .81rem; }
dialog { width: min(620px, calc(100% - 24px)); padding: 0; border: 1px solid var(--line); border-radius: 17px; color: var(--ink); background: var(--paper); max-height: calc(100dvh - 24px); box-shadow: 0 16px 80px #1d0f1b48; }
dialog::backdrop { background: #241a24a0; }
#dialog-body { padding: clamp(.9rem, 3vw, 1.35rem); min-width: 0; }
.manual-dialog {
  width: min(960px, calc(100% - 20px)); height: min(90dvh, 960px);
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 20px);
  padding: 0; overflow: hidden;
}
.manual-dialog[open] { display: flex; flex-direction: column; }
.manual-toolbar {
  flex: none; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px;
  padding: 12px 16px; background: #fff8fc; border-bottom: 1px solid #ddcbd5;
}
.manual-toolbar h2 { font-size: 1.2rem; }
.manual-version { font-size: .875rem; color: var(--muted); margin-top: .2rem; }
.manual-tools { display: flex; flex: none; gap: 6px; }
.manual-toolbar > div:first-child { min-width: 0; }
.manual-tools button { min-height: 48px; font-size: 1rem; padding-inline: .7rem; }
#manual-close { border-color: #d9a5bf; color: var(--accent-strong); background: var(--wash); }
.manual-scroll { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: clamp(14px, 3vw, 28px); font-size: 1rem; line-height: 1.85; }
.manual-scroll strong { color: #612a48; }
.manual-intro { margin-bottom: 18px; }
.manual-toc { display: grid; gap: 8px; margin-bottom: 24px; }
.manual-toc p { margin-bottom: 4px; }
.manual-toc button { text-align: left; justify-content: flex-start; min-height: 52px; font-size: 1rem; padding: .65rem .85rem; }
.manual-chapter { border: 1px solid var(--line); border-radius: 12px; margin-block: 12px; }
.manual-chapter > summary { padding: 16px; min-height: 56px; font-size: 1.05rem; line-height: 1.6; }
.manual-chapter[open] > summary { background: var(--wash); border-radius: 12px 12px 0 0; border-bottom: 1px solid var(--line); }
.manual-chapter-body { padding: 16px; display: grid; gap: 15px; }
.manual-chapter-body h4 { font-size: 1.1rem; margin-top: 5px; line-height: 1.6; }
.manual-list { margin: 0; padding-left: 1.5rem; display: grid; gap: 12px; }
.manual-note { padding: 14px; border-left: 4px solid #ba7da0; border-radius: 6px; background: #faf0f6; overflow-wrap: anywhere; }
.manual-flow { padding-left: 0; list-style-position: inside; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; }
.manual-flow li { padding: 12px; border: 1px solid #e3c8d8; border-radius: 10px; background: #fff7fb; }
.manual-faq { display: grid; gap: 8px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.manual-back, #manual-back-top { min-height: 48px; font-size: 1rem; justify-self: start; }
@media (max-width: 520px) {
  .manual-toolbar { padding: 10px; }
  .manual-toolbar h2 { font-size: 1.05rem; }
  .manual-version { max-width: 130px; }
  .manual-tools button { padding-inline: .55rem; }
  .manual-flow { grid-template-columns: minmax(0, 1fr); }
  .manual-chapter-body { padding: 14px; }
}
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; white-space: nowrap; clip-path: inset(50%); }
.skip:focus { position: fixed; top: 4px; left: 4px; z-index: 4; padding: .55rem; background: white; }
.drawing .card { animation: draw-card .5s ease both; }
@keyframes draw-card { 0% { opacity: .5; transform: translateY(3px); } 100% { opacity: 1; transform: translateY(0); } }
@media (max-width: 460px) {
  .main-tabs button { padding-inline: .25rem; gap: .25rem; font-size: .85rem; }
  .main-tabs .tab-icon { font-size: .95rem; }
}
@media (max-width: 679px), (max-width: 950px) and (max-height: 500px) and (pointer: coarse) {
  :root {
    --mobile-nav-height: 88px;
    --mobile-subtabs-height: 0px;
    --keyboard-inset: 0px;
    --visual-viewport-top: 0px;
    scroll-padding-top: calc(var(--mobile-subtabs-height) + 12px);
    scroll-padding-bottom: calc(var(--mobile-nav-height) + var(--keyboard-inset) + 16px);
  }
  body {
    padding-bottom: calc(var(--mobile-nav-height) + var(--keyboard-inset) + 16px);
    padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px);
  }
  html[data-page="search"] body { padding-top: var(--mobile-subtabs-height); }
  .site-header { padding-top: env(safe-area-inset-top, 0px); }
  html[data-page="search"] .site-header { padding-top: 0; }
  .main-tabs.main-tabs {
    position: fixed; z-index: 30;
    left: 0; right: 0; bottom: var(--keyboard-inset);
    width: auto; max-width: none; margin: 0;
    padding: 7px max(6px, env(safe-area-inset-right, 0px)) max(7px, env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px));
    gap: 5px; border: 0; border-top: 1px solid #ddcbd5;
    border-radius: 15px 15px 0 0; background: #fffefd;
    box-shadow: 0 -4px 18px #38202f12;
  }
  .main-tabs button {
    flex-direction: column; min-height: 64px; padding: .42rem .2rem;
    gap: .25rem; font-size: 1rem; line-height: 1.3; border-radius: 10px;
  }
  .main-tabs .tab-icon, .main-tabs .tab-icon.sparkle { font-size: 1.5rem; line-height: 1; min-height: 24px; }
  .main-tabs .records-icon { display: inline-flex; }
  .main-tabs button[aria-current="page"] { background: var(--wash); border-color: #d9a5bf; box-shadow: inset 0 0 0 1px #e9c4d7; }
  .search-subtabs {
    position: fixed; z-index: 31;
    top: var(--visual-viewport-top); left: 0; right: 0;
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    padding: calc(7px + env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) 7px max(14px, env(safe-area-inset-left, 0px));
    background: #fffefd; border-bottom: 1px solid #ddcbd5; box-shadow: 0 3px 12px #38202f0d;
  }
  .search-subtabs button { min-height: 48px; font-size: 1.05rem; }
  .search-subtabs button[aria-selected="true"] { color: var(--accent-strong); background: var(--wash); border: 2px solid #a4557e; }
  .search-grid.search-grid { grid-template-columns: minmax(0, 1fr); }
  .ai-panel.ai-panel { position: static; }
  #view-title, #ai-panel-title, #notice, #storage-notice, [role="tabpanel"] { scroll-margin-top: 12px; }
  input, textarea, select { scroll-margin-block: calc(var(--mobile-subtabs-height) + 12px) calc(var(--mobile-nav-height) + 16px); }
  textarea, input:not([type="checkbox"], [type="radio"]), select { font-size: 1rem; }
}
@media (min-width: 680px) {
  .frame { width: min(100% - 52px, 1184px); }
  .header-inner { min-height: 64px; }
  .utility { gap: .5rem; }
  .utility button { padding-inline: .75rem; }
  #workspace { padding-top: 27px; }
  .hero { min-height: 201px; }
  .main-tabs { margin-block: 18px 21px; max-width: 570px; }
  .presets-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 850px) {
  .search-grid { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; }
  .ai-panel { position: sticky; top: 12px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; } }
.reduce *, .reduce *::before, .reduce *::after { animation: none !important; scroll-behavior: auto !important; }
