:root {
  --bg: #f6f3ea; --fg: #202124; --muted: #5f6368; --line: #dadce0; --accent: #b06000; --card: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "BIZ UDPGothic", "Yu Gothic UI", Meiryo, sans-serif;
  line-break: strict; word-break: normal; overflow-wrap: anywhere;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font-size: 15px; line-height: 1.6; }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 12px; color: inherit; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.icon { border: none; background: transparent; font-size: 20px; padding: 6px 10px; border-radius: 50%; }
button.icon:hover, button.mini:hover { background: rgba(0,0,0,.07); }
button.icon.on { background: rgba(176,96,0,.15); }
input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; width: 100%; background: #fff; color: inherit; }
label { display: block; margin: 12px 0; color: var(--muted); font-size: 14px; }
label input { margin-top: 4px; color: var(--fg); font-size: 16px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--fg); }
label.check input { width: auto; margin: 0; }
[hidden] { display: none !important; }

/* 入口 */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.gate-box { width: min(440px, 100%); background: #fff; border-radius: 16px; padding: 28px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.gate-box h1 { margin: 0 0 8px; font-size: 22px; }
.gate-box .primary { width: 100%; padding: 10px; margin-top: 8px; }
.lead { color: var(--muted); font-size: 14px; }
.msg { color: #c5221f; min-height: 1.6em; font-size: 14px; }
.recovery-code { font-family: ui-monospace, Consolas, monospace; font-size: 20px; letter-spacing: .06em; background: #fff7e0; border: 1px dashed var(--accent); border-radius: 10px; padding: 14px; text-align: center; word-break: break-all; user-select: all; }
details.recover { margin-top: 18px; font-size: 14px; }
details.recover summary { cursor: pointer; color: var(--muted); }

/* 上の帯 */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { font-size: 20px; font-weight: 600; white-space: nowrap; margin-right: 8px; }
#search { max-width: 720px; flex: 1; background: #ece8dc; border: none; padding: 10px 14px; }
#search:focus { background: #fff; outline: 1px solid var(--line); }
.sync-state { color: #c5221f; font-size: 13px; white-space: nowrap; }
.lock { white-space: nowrap; }

.body { display: flex; }
.side { width: 220px; flex: none; padding: 8px 0; position: sticky; top: 57px; align-self: flex-start; max-height: calc(100vh - 57px); overflow: auto; }
.nav { display: block; width: 100%; text-align: left; border: none; background: transparent; border-radius: 0 24px 24px 0; padding: 10px 20px; }
.nav.on { background: #feefc3; font-weight: 600; }
.nav:hover { background: rgba(0,0,0,.05); }
.content { flex: 1; padding: 16px 20px 80px; min-width: 0; }

.composer { max-width: 600px; margin: 8px auto 24px; background: #fff; border-radius: 10px; padding: 12px 16px; color: var(--muted); box-shadow: 0 1px 3px rgba(0,0,0,.15); cursor: text; }
.empty { text-align: center; color: var(--muted); margin-top: 60px; }
.sec-h { font-size: 12px; letter-spacing: .08em; color: var(--muted); margin: 16px 8px 8px; font-weight: 500; }

/* 石積み（カラム） */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); grid-auto-rows: 4px; column-gap: 14px; align-items: start; }
.card { break-inside: avoid; display: block; width: 100%; margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 4px; position: relative; cursor: default; }
.card:hover { box-shadow: 0 1px 6px rgba(0,0,0,.18); }
.c-title { font-size: 16px; margin: 0 0 6px; font-weight: 600; }
.c-body { font-size: 14px; }
.line { display: flex; align-items: flex-start; gap: 6px; min-height: 1.6em; }
.line .txt { flex: 1; white-space: pre-wrap; user-select: text; min-width: 0; }
.line .mask { letter-spacing: .1em; color: var(--muted); user-select: none; }
.line.done .txt { text-decoration: line-through; color: var(--muted); }
.line .cb { color: var(--muted); }
button.mini { border: none; background: transparent; padding: 0 6px; font-size: 15px; line-height: 1.6; border-radius: 6px; color: var(--muted); }
.line .copy { color: var(--accent); font-size: 12px; border: 1px solid currentColor; padding: 0 6px; margin-left: 4px; white-space: nowrap; align-self: center; line-height: 1.5; }
.line .eye { align-self: center; }
.c-imgs { margin: -12px -14px 8px; }
.c-img { display: block; width: 100%; height: auto; border-radius: 10px 10px 0 0; }
.c-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.chip { font-size: 12px; background: rgba(0,0,0,.08); border-radius: 10px; padding: 0 8px; }
.c-bar { display: flex; gap: 2px; justify-content: flex-end; opacity: 0; transition: opacity .15s; min-height: 28px; }
.card:hover .c-bar, .card:focus-within .c-bar { opacity: 1; }
@media (hover: none) { .c-bar { opacity: 1; } }

/* 色 */
.color-default { --card: #fff; }
.color-red { --card: #faafa8; } .color-orange { --card: #f39f76; } .color-yellow { --card: #fff8b8; }
.color-green { --card: #e2f6d3; } .color-teal { --card: #b4ddd3; } .color-blue { --card: #d4e4ed; }
.color-darkblue { --card: #aeccdc; } .color-purple { --card: #d3bfdb; } .color-pink { --card: #f6e2dd; }
.color-brown { --card: #e9e3d4; } .color-gray { --card: #efeff1; }
.swatch { width: 24px; height: 24px; border-radius: 50%; padding: 0; background: var(--card); border: 1px solid #bbb; }
.swatch.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.colors { display: inline-flex; flex-wrap: wrap; gap: 4px; }

/* 編集 */
dialog.editor { border: none; border-radius: 12px; padding: 0; width: min(640px, 96vw); max-height: 92vh; box-shadow: 0 8px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.ed-box { background: var(--card); padding: 16px; display: flex; flex-direction: column; max-height: 92vh; }
.ed-box h2 { margin: 0 0 8px; font-size: 18px; }
.ed-title { border: none; font-size: 18px; font-weight: 600; background: transparent; padding: 6px 4px; }
.ed-title:focus, .l-text:focus { outline: none; background: rgba(255,255,255,.5); }
.ed-hint { color: var(--muted); font-size: 12px; margin: 2px 4px 8px; }
.ed-lines { overflow: auto; flex: 1; min-height: 80px; }
.ed-line { display: flex; align-items: center; gap: 2px; }
.ed-line .l-text { border: none; background: transparent; padding: 4px 6px; flex: 1; min-width: 0; }
.ed-line .l-text.secret { -webkit-text-security: disc; }
.ed-line .l-check { width: auto; margin: 0 4px; }
button.tog { border: 1px solid #e0e0e0; background: transparent; padding: 0 5px; font-size: 11px; color: #a0a0a0; white-space: nowrap; margin-right: 2px; border-radius: 6px; line-height: 1.8; }
button.tog.on { color: #fff; background: var(--accent); }
button.tog.del { color: #c0c0c0; border-color: transparent; font-size: 14px; }
button.tog:hover { border-color: var(--line); }
.ed-images img { max-height: 200px; width: auto; border-radius: 8px; margin: 6px 4px 0 0; display: inline-block; }
.ed-labels { margin: 8px 4px; }
.ed-labels input { background: rgba(255,255,255,.6); font-size: 14px; }
.ed-bar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.spacer { flex: 1; }

.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 28px 16px; text-align: center; color: var(--muted); margin: 8px 0; }
.drop.over { border-color: var(--accent); background: #fff7e0; }
.drop input { margin-top: 10px; width: auto; border: none; }
.import-summary .big { font-size: 16px; font-weight: 600; }
.import-summary .small { font-size: 12px; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: #323232; color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; font-size: 14px; }
.toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

/* スマホ */
@media (max-width: 720px) {
  .brand { display: none; }
  .lock { font-size: 0; padding: 6px 10px; }
  .lock::before { content: "🔒"; font-size: 18px; }
  .side { position: fixed; left: 0; top: 57px; bottom: 0; background: var(--bg); z-index: 20; transform: translateX(-100%); transition: transform .2s; max-height: none; box-shadow: 2px 0 12px rgba(0,0,0,.15); }
  body.side-open .side { transform: none; }
  .content { padding: 10px 8px 80px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 8px; }
  .card { margin-bottom: 0; padding: 10px 10px 2px; }
  .c-imgs { margin: -10px -10px 8px; }
}
@media (min-width: 721px) { #menu-btn { display: none; } }

.c-dates { color: var(--muted); font-size: 11px; margin: 0 0 7px; }
.sort-label { margin: 0 0 8px; text-align: right; }
.sort-label select { font: inherit; max-width: 100%; padding: 5px; }
#import-notice { background: #fff7e0; border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
#import-notice button { margin-left: 8px; }
.help { width: 320px; flex: none; position: sticky; top: 57px; height: calc(100vh - 57px); overflow: auto; padding: 16px; background: #fff; border-left: 1px solid var(--line); }
.help-head { display: flex; justify-content: space-between; align-items: center; }
.help-head h2 { margin: 0 0 8px; font-size: 18px; }
.help-item { padding: 6px 8px; border-radius: 8px; }
.help-item h3 { font-size: 15px; margin: 4px 0; }
.help-item p { font-size: 13px; margin: 4px 0; }
.help-active { background: #feefc3; }
@media (max-width: 720px) { .help { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 30; border: 0; } }

.view-box { background: var(--card); display:flex; flex-direction:column; max-height:90vh; }
.view-top, .view-actions { display:flex; align-items:center; gap:8px; padding:12px 16px; flex-wrap:wrap; }
.view-top strong { flex:1; }
.view-content { overflow:auto; padding:0 16px 16px; overflow-wrap:anywhere; }
.view-content h2 { margin:8px 0; }
.view-lines { margin:16px 0; }
.view-check { width:auto; margin:5px 0; }
.view-image { display:block; width:100%; height:auto; margin:10px 0; cursor:zoom-in; }
.view-color { margin-top:8px; font-size:12px; }
dialog.photo { border:0; padding:0; background:transparent; max-width:100vw; max-height:100vh; }
dialog.photo::backdrop { background:rgba(0,0,0,.9); }
.photo img { display:block; max-width:96vw; max-height:94vh; object-fit:contain; cursor:zoom-out; }
#photo-close { position:fixed; right:12px; top:12px; z-index:1; font-size:24px; }
