:root {
  color-scheme: light;
  --paper: #faf8f4;
  --surface: #fffcf8;
  --white: #fffefa;
  --ink: #2f2823;
  --soft: #685b51;
  --line: #e6ded4;
  --accent: #9d412e;
  --accent-dark: #823323;
  --peach: #f4e4da;
  --olive: #4c5a41;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif CJK JP", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.65 var(--sans); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid #966941; outline-offset: 4px; }
.symbols { position: absolute; width: 0; height: 0; pointer-events: none; }
.icon { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: middle; }
.sr-only, .skip-link:not(:focus) { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }
.skip-link:focus { position: fixed; z-index: 5; background: white; padding: 10px 16px; top: 8px; left: 8px; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; padding: 33px 22px 22px; border-right: 1px solid var(--line); background: #fdfaf5; }
.brand { display: flex; align-items: center; gap: 12px; width: fit-content; margin: 0 0 42px 4px; }
.brand-mark { width: 45px; height: 45px; display: inline-grid; place-items: center; border-radius: 13px; background: var(--accent); color: #fff9ef; flex: none; }
.brand-mark .icon { width: 25px; height: 25px; }
.brand-name { font-family: var(--serif); font-size: 11px; line-height: 1.35; letter-spacing: .1em; }
.brand-name span { display: block; font-size: 17px; font-weight: 800; letter-spacing: .035em; }
.nav { display: grid; gap: 5px; }
.nav-item { color: var(--soft); display: flex; align-items: center; gap: 12px; padding: 12px 13px; font-weight: 650; border-radius: 9px; min-height: 46px; white-space: nowrap; }
.nav-item:hover { background: #f3ede5; color: var(--ink); }
.nav-item.current { background: var(--peach); color: var(--accent-dark); }
.sidebar-footer { margin-top: auto; padding-top: 17px; border-top: 1px solid var(--line); }
.local-status { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--soft); margin: 2px 4px; }
.local-status span { width: 7px; height: 7px; border-radius: 50%; background: #788763; }
.signout { border: 0; background: transparent; width: 100%; }
.main { min-width: 0; }
.content { width: min(100%, 1290px); padding: 45px clamp(24px, 4vw, 64px) 52px; margin: auto; }

.page-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 26px; }
.page-header h1, .login-panel h1 { font: 800 clamp(29px, 3.3vw, 42px)/1.3 var(--serif); letter-spacing: .035em; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 43px; padding: 9px 15px; border-radius: 8px; font-weight: 700; border: 1px solid transparent; line-height: 1.35; white-space: nowrap; }
.button.primary { color: #fffaf3; background: var(--accent); border-color: var(--accent); }
.button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button.light { background: var(--white); color: var(--ink); border-color: #ded3c7; }
.button.light:hover { background: #f4ece2; }
.button.small { min-height: 36px; padding: 6px 10px; font-size: 12px; }
.button-row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.text-link { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-dark); font-weight: 700; overflow-wrap: anywhere; }
.text-link:hover, .back-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.back-link { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 17px; color: var(--soft); font-weight: 650; font-size: 13px; }
.quiet, .helper { color: var(--soft); }
.helper { font-size: 12px; margin-top: 5px; }
.preline { white-space: pre-wrap; overflow-wrap: anywhere; }

.import-hero { isolation: isolate; display: grid; align-items: center; grid-template-columns: minmax(0, 1.13fr) minmax(0, 1fr); border: 1px solid #e7d6c9; border-radius: 17px; min-height: 306px; overflow: hidden; background: #f4e8db; position: relative; }
.hero-copy { position: relative; z-index: 1; padding: 30px clamp(23px, 3.3vw, 51px); }
.hero-mark { display: inline-grid; place-items: center; width: 43px; height: 43px; color: var(--accent); background: #fbf3e9; border: 1px solid #e9d8c8; border-radius: 50%; margin-bottom: 13px; }
.hero-mark .icon { width: 23px; height: 23px; }
.hero-copy h2 { font: 800 clamp(25px, 3vw, 38px)/1.45 var(--serif); letter-spacing: .025em; }
.hero-copy p { margin-top: 9px; max-width: 34em; color: #5f4e40; }
.hero-actions { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 9px; }
.import-hero > img { position: absolute; inset: 0 0 0 auto; width: 47%; height: 100%; object-fit: cover; object-position: center 54%; }

.library { margin-top: 35px; }
.library-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.section-title { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.section-title h2, .panel h2 { font: 800 23px/1.4 var(--serif); letter-spacing: .035em; }
.count { color: var(--soft); background: #eee8de; border-radius: 12px; padding: 2px 9px; font-size: 11px; white-space: nowrap; }
.search-form { display: flex; align-items: center; min-width: 0; width: min(100%, 274px); border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.search-form:focus-within { outline: 2px solid #966941; outline-offset: 2px; }
.search-form input { width: 100%; min-height: 41px; min-width: 0; color: var(--ink); border: 0; outline: 0; background: transparent; padding: 7px 9px 7px 0; }
.search-button { padding: 8px 9px 8px 11px; border: 0; color: var(--soft); background: transparent; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 18px; }
.chip { border: 1px solid var(--line); border-radius: 999px; color: var(--soft); background: var(--white); padding: 5px 13px; font-size: 12px; font-weight: 650; }
.chip:hover { background: #f5efe7; }
.chip.chosen { background: var(--olive); color: #fffdf6; border-color: var(--olive); }
.empty-state { background: var(--surface); border: 1px dashed #d8cdbf; border-radius: 13px; display: grid; justify-items: center; gap: 7px; padding: 36px 18px; text-align: center; }
.empty-state h3 { font: 800 18px/1.5 var(--serif); }
.empty-state p { color: var(--soft); }
.empty-icon { width: 48px; height: 48px; border-radius: 50%; background: #f2e9de; color: #8b604a; display: grid; place-items: center; margin-bottom: 2px; }
.empty-icon .icon { width: 23px; height: 23px; }
.empty-state .icon:not(.empty-icon .icon) { width: 14px; }

.recipe-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.recipe-card { position: relative; min-width: 0; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.card-link { display: block; height: 100%; border-radius: inherit; }
.card-link:hover h3 { color: var(--accent-dark); }
.card-photo { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 12px 12px 0 0; }
.card-placeholder { background: #eee0d1; color: #8a6348; display: grid; place-items: center; }
.card-placeholder .icon { width: 31px; height: 31px; }
.card-placeholder[data-category="side"], .card-placeholder[data-category="staple"] { background: #e9ecdf; color: #596249; }
.card-placeholder[data-category="sweet"] { background: #f1e1dd; color: #95645b; }
.card-content { padding: 14px 16px 17px; }
.card-content h3 { margin: 6px 0 9px; font: 800 21px/1.45 var(--serif); }
.tag { display: inline-block; color: #594535; background-color: #efe6db; font-size: 11px; font-weight: 700; border-radius: 5px; padding: 2px 8px; }
.recipe-meta { display: flex; flex-wrap: wrap; gap: 12px; color: var(--soft); font-size: 13px; }
.recipe-meta span { display: inline-flex; align-items: center; gap: 4px; }
.recipe-meta .icon { width: 15px; height: 15px; }
.card-favorite { position: absolute; top: 9px; right: 9px; }
.icon-button { background: var(--white); color: var(--soft); border: 1px solid var(--line); border-radius: 50%; display: grid; place-items: center; width: 43px; height: 43px; }
.icon-button:hover, .icon-button.liked { color: var(--accent); }
.icon-button.liked .icon { fill: #e8b4a6; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 20px; }

.detail-heading { align-items: flex-end; }
.detail-heading h1 { margin: 5px 0 8px; }
.detail-heading .button-row { flex: none; }
.detail-cover { display: block; width: 100%; height: clamp(235px, 41vw, 415px); object-fit: cover; border-radius: 15px; margin-bottom: 19px; }
.recipe-columns { display: grid; grid-template-columns: minmax(0, .75fr) minmax(0, 1.25fr); gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; min-width: 0; }
.reading, .note-panel { padding: 21px clamp(16px, 2.9vw, 29px); margin-bottom: 16px; overflow-wrap: anywhere; }
.reading h2, .note-panel h2 { margin-bottom: 13px; }
.note-panel, .notes-field { background: #f5eadc; border-color: #ead9c8; }
.note-panel h2 .icon, .notes-field h2 .icon { color: var(--accent); }
.ingredients-list, .steps-list, .attachment-list, .edit-attachments { margin: 0; padding: 0; list-style: none; }
.ingredients-list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.ingredients-list li:last-child { border-bottom: 0; }
.steps-list { counter-reset: step; }
.steps-list li { counter-increment: step; display: grid; grid-template-columns: 26px 1fr; gap: 12px; padding: 8px 0; }
.steps-list li::before { content: counter(step); display: grid; place-items: center; height: 26px; border-radius: 50%; color: var(--accent-dark); background: var(--peach); font-size: 12px; font-weight: bold; }
.source-link { align-items: flex-start; }
.attachment-list { display: grid; gap: 7px; margin-top: 9px; }
.attachment-list a { display: flex; align-items: center; gap: 12px; padding: 5px 0; }
.attachment-list a:hover { color: var(--accent-dark); }
.attachment-list img, .file-icon { border-radius: 6px; object-fit: cover; }
.file-icon { display: grid; place-items: center; width: 70px; height: 54px; background: #f0e6da; color: var(--soft); }
.attachment-list small { display: block; color: var(--soft); }
.transcript { margin-top: 15px; }
.transcript summary, .crop-numbers summary { color: var(--soft); cursor: pointer; font-weight: 650; }
.transcript[open] summary { margin-bottom: 10px; }

.editor-heading { margin-bottom: 22px; }
.editor-panel { padding: clamp(17px, 3vw, 28px); margin-bottom: 16px; }
.editor-panel h2 { margin-bottom: 16px; }
.editor-panel > label, .field > label, [data-mode-panel] > label:first-child { font-weight: 700; display: block; margin-bottom: 6px; }
.mode-tabs { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.mode-tabs a { display: inline-flex; gap: 7px; align-items: center; padding: 7px 12px; color: var(--soft); border: 1px solid var(--line); border-radius: 8px; font-weight: 700; }
.mode-tabs a:hover { background: #f4ede4; }
.mode-tabs a.selected { color: var(--accent-dark); background: var(--peach); border-color: #ead2c3; }
.mode-tabs .icon { width: 17px; height: 17px; }
.mode-tabs:last-child { margin-bottom: 0; }
.import-panel:has([data-mode="manual"].selected) .mode-tabs { margin-bottom: 0; }
.input-action { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; max-width: 720px; }
.field { min-width: 0; margin-bottom: 13px; }
.field .helper { margin: -4px 0 6px; }
.field input + .helper { margin: 5px 0 0; }
.field input:not([type="checkbox"], [type="radio"]), .field select, .editor-panel textarea, .input-action input, #book-photo, .crop-fields input {
  width: 100%; min-width: 0; min-height: 42px; padding: 8px 11px; border-radius: 8px;
  border: 1px solid #ded4c9; background: var(--white); color: var(--ink);
}
textarea { resize: vertical; line-height: 1.7; }
input::placeholder, textarea::placeholder { color: #7d7065; }
input[type="file"]::file-selector-button { border: 1px solid var(--line); background: #f2ebe2; color: var(--ink); border-radius: 5px; padding: 3px 8px; margin-right: 8px; cursor: pointer; }
#book-photo { max-width: 560px; }
.fields-two, .fields-three { display: grid; gap: 13px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.checkbox { display: flex; gap: 6px; align-items: center; color: var(--soft); cursor: pointer; min-height: 26px; width: fit-content; }
.checkbox input { accent-color: var(--accent); }
#import-image-option { margin-top: 8px; }
.import-status:not(:empty) { margin-top: 8px; color: var(--olive); font-size: 13px; font-weight: 650; }
.import-status.error-text, .errorlist { color: #973a2b; }
.errorlist { margin: 5px 0; padding-left: 20px; }
.book-preview { display: grid; grid-template-columns: fit-content(60%) minmax(0, 1fr); align-items: start; gap: 16px; margin-top: 12px; }
.crop-area { display: table; max-width: 100%; position: relative; overflow: hidden; isolation: isolate; line-height: 0; border-radius: 8px; cursor: crosshair; touch-action: none; user-select: none; }
.crop-area img { display: block; max-height: 475px; max-width: 100%; width: auto; height: auto; user-select: none; pointer-events: none; }
.crop-area { width: fit-content; }
.crop-box { position: absolute; border: 2px solid white; box-shadow: 0 0 0 9999px #291d166e, inset 0 0 0 1px #7c3d2f; pointer-events: none; }
.crop-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 8px; }
.crop-tools .helper { margin: 0; }
.crop-numbers { font-size: 12px; margin-top: 8px; }
.crop-fields { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 7px; }
.crop-fields label { display: grid; gap: 3px; }
.crop-fields input { min-height: 34px; width: 72px; padding: 4px 7px; }
.photo-controls .crop-tools { margin-top: 15px; }
.existing-cover { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.existing-cover img { object-fit: cover; border-radius: 6px; }
.edit-attachments { margin: 6px 0; }
.edit-attachments li { border-top: 1px solid var(--line); display: flex; align-items: center; gap: 6px 17px; flex-wrap: wrap; padding: 6px 0; }
.edit-attachments li > a { margin-right: auto; }
.editor-footer { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.delete-area { margin-top: 27px; padding-top: 14px; border-top: 1px solid var(--line); }
.delete-area summary { color: var(--accent-dark); font-size: 13px; cursor: pointer; }
.delete-area form { margin-top: 10px; }
.delete-area form p { margin-bottom: 9px; }
.notifications { display: grid; gap: 6px; margin-bottom: 15px; }
.notice { padding: 10px 13px; border-radius: 8px; background: #edf0e6; color: #3d5539; border: 1px solid #dbe2ce; }
.notice.warning, .notice.error { background: #faebe4; color: #8b3928; border-color: #eacdc1; }
#form-errors { margin-bottom: 14px; }
.notice ul { margin: 0; padding-left: 20px; }
.login-page { min-height: 100vh; display: grid; place-items: center; background: #f4ebe1; padding: 20px; }
.login-panel { width: min(100%, 420px); padding: clamp(22px, 4vw, 40px); }
.login-panel h1 { font-size: 26px; margin: 14px 0 20px; }

@media (max-width: 1050px) {
  .shell { grid-template-columns: 200px minmax(0, 1fr); }
  .sidebar { padding-inline: 15px; }
  .import-hero { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
  .import-hero > img { width: 43%; }
  .hero-actions .button { padding-inline: 9px; font-size: 12px; }
  .recipe-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { display: flex; flex-direction: row; align-items: center; gap: 13px; justify-content: space-between; position: static; height: auto; padding: 10px 16px; border: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0; gap: 8px; }
  .brand-mark { width: 37px; height: 37px; border-radius: 10px; }
  .brand-mark .icon { width: 22px; height: 22px; }
  .brand-name { font-size: 9px; }
  .brand-name span { font-size: 14px; }
  .nav { display: flex; gap: 3px; }
  .nav-item { min-height: 36px; padding: 6px 9px; font-size: 11px; gap: 5px; }
  .nav-item .icon { width: 15px; height: 15px; }
  .sidebar-footer { margin: 0; padding: 0; border: 0; }
  .sidebar-footer:has(.local-status) { display: none; }
  .signout { padding-inline: 3px; }
  .content { padding: 25px 16px 32px; }
  .hero-copy { padding: 23px 22px; }
  .import-hero { min-height: 245px; }
  .page-header { margin-bottom: 19px; }
}
@media (max-width: 520px) {
  .sidebar:has(.signout) { flex-wrap: wrap; }
  .sidebar:has(.signout) .sidebar-footer { margin-left: auto; }
  .content { padding-inline: 14px; }
  .page-header h1 { font-size: 28px; }
  .page-header .button { padding-inline: 10px; font-size: 12px; }
  .page-header .button .icon { width: 16px; height: 16px; }
  .import-hero { grid-template-columns: minmax(0, 1fr); }
  .import-hero > img { position: static; width: 100%; height: clamp(122px, 42vw, 190px); object-position: 50% 51%; }
  .hero-copy { padding: 16px 16px 19px; }
  .hero-mark { display: none; }
  .hero-copy h2 { font-size: 25px; }
  .hero-copy p { margin-top: 5px; font-size: 12px; }
  .hero-actions { margin-top: 14px; }
  .hero-actions .button { min-height: 39px; }
  .hero-actions .icon { width: 16px; height: 16px; }
  .library { margin-top: 24px; }
  .library-header { flex-wrap: wrap; gap: 10px; }
  .search-form { width: 100%; }
  .section-title h2, .panel h2 { font-size: 20px; }
  .chips { gap: 5px; }
  .chip { padding: 4px 9px; }
  .recipe-grid { gap: 9px; }
  .card-content { padding: 9px 10px 12px; }
  .card-content h3 { font-size: 16px; }
  .card-favorite { top: 6px; right: 6px; }
  .card-favorite .icon-button { width: 35px; height: 35px; }
  .recipe-meta { gap: 7px; font-size: 11px; }
  .detail-heading { align-items: flex-start; }
  .detail-heading .button-row { justify-content: flex-end; }
  .detail-heading .icon-button { width: 38px; height: 38px; }
  .detail-heading .button { min-height: 38px; }
  .detail-cover { height: clamp(180px, 58vw, 290px); }
  .recipe-columns, .fields-two { display: block; }
  .book-preview { display: flex; flex-direction: column; gap: 10px; }
  .photo-controls { order: -1; }
  .fields-three { gap: 6px; }
  .field label { font-size: 12px; }
  .editor-panel :is(input[type="text"], input[type="url"], input[type="number"], select, textarea), .search-form input, .login-panel input { font-size: 16px; }
}
@media (prefers-reduced-motion: no-preference) {
  .button, .nav-item, .chip { transition: color .12s ease, background-color .12s ease, border-color .12s ease; }
}
