* { box-sizing:border-box; }
body, h1, h2, h3, ul, p, form { margin:0; }
button, input { font:inherit; color:inherit; }
button { background:transparent; border:0; padding:0; }
svg { display:block; }
[hidden] { display:none !important; }
.fd { min-height:100dvh; background:#f6f7f3; color:#192e29; font:15px/1.45 "Inter",system-ui,sans-serif; }
.fd button:enabled { cursor:pointer; }
.fd button:focus-visible,.fd input:focus-visible { outline:3px solid #167066; outline-offset:3px; }
.fd-bar { position:sticky; top:0; z-index:1; background:#fff; height:52px; padding:0 16px; border-bottom:1px solid #d7ded8; display:flex; align-items:center; gap:6px; }
.fd-icon { flex:none; width:34px; height:34px; display:grid; place-items:center; border-radius:6px; }
.fd-guide-close { width:44px; height:44px; }
.fd-icon:first-child { margin-right:5px; }
.fd-icon:enabled:hover { background:#eff4ee; }
.fd-bar h1 { margin:0; font-size:15px; font-weight:600; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.fd-save { flex:none; margin-left:6px; color:#50665c; font-size:12px; }
.fd-save button { text-decoration:underline; margin-left:4px; }
.fd-library { max-width:1060px; margin:auto; padding:clamp(36px,8vw,96px) 24px; }
.fd-heading { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:14px; margin-bottom:36px; }
.fd-heading h1 { font-size:clamp(32px,5vw,48px); letter-spacing:-.045em; font-weight:600; }
.fd-new { display:inline-flex; align-items:center; gap:8px; background:#16594f; color:white; border-radius:7px; padding:10px 16px; }
.fd-library h3 { font-size:15px; font-weight:600; margin-bottom:14px; }
.fd-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,230px),1fr)); gap:18px; }
.fd-card { min-width:0; text-align:left; border:1px solid #d4dcd5; border-radius:12px; background:white; overflow:hidden; padding:8px 8px 14px; }
.fd-card:hover { border-color:#6e9286; }
.fd-cover { display:flex; align-items:center; justify-content:space-between; aspect-ratio:16/9; padding:8%; border-radius:5px; overflow:hidden; color:#24413a; gap:4%; }
.fd-cover span { font:500 clamp(20px,2vw,30px)/1.07 Georgia,serif; overflow-wrap:anywhere; }
.fd-cover svg { width:39%; flex:none; opacity:.65; }
.fd-card strong,.fd-card small { display:block; margin:10px 7px 0; }
.fd-card small { margin-top:2px; color:#5c6d65; }
.fd-name { max-width:100%; overflow:hidden; text-overflow:ellipsis; vertical-align:middle; border-radius:4px; padding:2px 4px; }
.fd-name:hover { background:#eff4ee; }
.fd-rename { width:22ch; max-width:100%; padding:2px 4px; background:white; border-radius:4px; }
.fd-sync { margin-inline-start:auto; }
#download:disabled { opacity:.5; }
#actions { margin:48px 12px auto auto; min-width:170px; padding:4px; border:1px solid #cbd6cd; border-radius:8px; background:white; color:#192e29; box-shadow:0 8px 28px #203b3217; }
#actions button { width:100%; display:flex; align-items:center; gap:9px; padding:8px; border-radius:4px; text-align:left; }
#actions button:hover { background:#eff4ee; }
#actions button:disabled { opacity:.5; }
body:has(#library:not([hidden])) .fd-bar { background:#f6f7f3; border-bottom:0; }
.fd-settings { margin:auto; width:min(420px,calc(100vw - 32px)); max-height:85dvh; overflow:auto; padding:24px; border:1px solid #cbd6cd; border-radius:14px; background:white; color:#192e29; box-shadow:0 16px 60px #203b3229; }
.fd-settings::backdrop { background:#142d2545; }
.fd-settings-heading,.fd-row { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.fd-settings h2 { font-size:21px; font-weight:600; }
.fd-settings section { margin-top:20px; }
.fd-settings h3 { margin-bottom:6px; font-size:14px; font-weight:650; }
.fd-settings p,.fd-row { font-size:14px; color:#50665c; }
#download-dialog a { overflow-wrap:anywhere; }
.fd-row small { display:block; }
.fd-row button { border:1px solid #cbd6cd; border-radius:6px; padding:5px 10px; white-space:nowrap; }
.fd-row button:disabled { opacity:.55; }

.fd-row { flex-wrap:wrap; }
.fd-sync-actions { display:flex; gap:6px; }
.fd { margin:0; }
.fd-icon svg { flex:none; }
.fd-new svg { width:17px; height:17px; }
.fd-grid { padding:0; list-style:none; grid-template-columns:repeat(auto-fill,minmax(min(100%,max(230px,calc((100% - 36px)/3))),1fr)); }
.fd-grid li { min-width:0; }
.fd-card { width:100%; display:block; }
.fd-cover { background:#d4e5df; }
[data-file-type="plain-text"] { --file-color:#d4e5df; }
[data-file-type="diagrams"] { --file-color:#e7ddcd; }
[data-file-type="mind-map"] { --file-color:#dce0ef; }
[data-file-type="whiteboard"] { --file-color:#f0dfdf; }
[data-file-type="ledger"] { --file-color:#e3ead2; }
[data-file-type="wiki"] { --file-color:#e7ddec; }
[data-file-type="pixel-editor"] { --file-color:#f0e3c7; }
.fd-cover,.fd-type-icon { background:var(--file-color,#d4e5df); }
.fd-type-glyph { fill:none; stroke:currentColor; stroke-width:1.5; stroke-linecap:round; stroke-linejoin:round; }
.fd-cover span { min-width:0; display:-webkit-box; -webkit-line-clamp:4; -webkit-box-orient:vertical; overflow:hidden; }
.fd-card strong { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.fd-card small { font-size:12px; }
.fd-import { cursor:pointer; font-size:14px; color:#50665c; }
.fd-import:focus-within { outline:3px solid #167066; }
.fd-import input { position:absolute; width:1px; height:1px; opacity:0; }
#empty { padding:20px 0; color:#5c6d65; }
#status:not(:empty) { margin:.35rem 1rem; font-size:13px; }
#editor { flex:1; min-height:0; }
body:has(#editor:not([hidden])) { display:flex; flex-direction:column; height:100dvh; }
iframe { width:100%; height:100%; display:block; border:0; }
#cloud svg g { display:none; }
#cloud[data-state="local"] .local, #cloud[data-state="attention"] .attention,
#cloud[data-state="synced"] .synced, #cloud[data-state="syncing"] .syncing { display:inline; }
#history button, #items li > button:not(.fd-card) { text-decoration:underline; padding:4px; }
.fd-heading h1, .fd-library h3 { line-height:1.5; }
.fd-recent { display:flex; align-items:baseline; justify-content:space-between; gap:12px; }
.fd-card strong { line-height:1.5; }
.fd-new { line-height:24px; }
.fd-card strong { font-size:16px; }
.fd-card small { font-size:13px; line-height:1.5; }

.fd-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; width:min(100%,232px); }
.fd-actions .fd-new { justify-content:center; padding:8px 12px; min-width:0; border:1px solid #16594f; }
.fd-secondary { background:white; color:#16594f; }
.fd-card { overflow:visible; padding-bottom:6px; }
.fd-open { display:block; width:100%; text-align:left; }
.fd-open strong { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.fd-open .fd-cover { justify-content:center; }
.fd-open .fd-cover svg { width:clamp(26px,5vw,44px); height:auto; }
.fd-meta { display:flex; align-items:center; justify-content:space-between; gap:4px; padding-left:7px; color:#5c6d65; font-size:13px; }
.fd-meta time { min-width:0; overflow-wrap:anywhere; }
.fd-meta details { position:relative; flex:none; }
.fd-meta summary { display:grid; place-items:center; list-style:none; cursor:pointer; width:34px; height:34px; }
.fd-meta summary::-webkit-details-marker { display:none; }
.fd-file-menu { position:absolute; z-index:2; right:0; bottom:100%; padding:4px; min-width:96px; background:white; border:1px solid #cbd6cd; border-radius:8px; box-shadow:0 6px 18px #203b3217; }
.fd-file-menu button { display:block; width:100%; text-align:left; padding:6px 10px; }
.fd-file-menu button:hover { background:#eff4ee; }
.fd-work textarea { width:100%; height:calc(100dvh - 52px); padding:16px; background:white; font:16px/1.6 monospace; }
.fd-create { margin:auto; width:min(520px,calc(100vw - 24px)); max-height:calc(100dvh - 24px); overflow:auto; padding:0; border:1px solid #cbd6cd; border-radius:14px; background:white; color:inherit; box-shadow:0 16px 60px #203b3229; }
.fd-create::backdrop { background:#142d2550; }
.fd-create form { display:grid; grid-template-columns:minmax(0,1fr); gap:16px; padding:20px; }
.fd-create-head { display:flex; align-items:center; justify-content:space-between; gap:4px; }
.fd-create-head h2 { font-size:22px; font-weight:650; letter-spacing:-.025em; }
.fd-type-list { min-width:0; margin:0; padding:0; border:0; }
.fd-type-list legend,.fd-create-name label { margin-bottom:7px; font-size:13px; font-weight:600; }
.fd-type-list > div { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.fd-type-option { display:flex; align-items:center; min-width:0; gap:9px; padding:8px; border:1px solid #d4dcd5; border-radius:8px; cursor:pointer; position:relative; }
.fd-type-option:hover { background:#f6f7f3; }
.fd-type-option:has(:checked) { border-color:#16594f; background:#eef5ef; box-shadow:inset 0 0 0 1px #16594f; }
.fd-type-option:has(:focus-visible) { outline:2px solid #167066; outline-offset:2px; }
.fd-type-option input { position:absolute; width:1px; height:1px; opacity:0; }
.fd-type-icon { flex:none; width:34px; height:34px; display:grid; place-items:center; border-radius:6px; }
.fd-type-option strong,.fd-type-option small { display:block; overflow-wrap:anywhere; }
.fd-type-option strong { font-size:14px; }
.fd-type-option small { color:#50665c; font-size:12px; }
.fd-create-name { display:grid; grid-template-columns:minmax(0,1fr); }
.fd-create-name > div { display:flex; align-items:center; border:1px solid #cbd6cd; border-radius:7px; }
.fd-create-name > div:focus-within { outline:2px solid #167066; }
.fd-create-name input { flex:1; min-width:0; width:0; padding:8px 10px; background:transparent; border:0; }
.fd-create-name input:focus-visible { outline:none; }
.fd-create-name input:disabled { opacity:.62; }
.fd-create-name span { padding-right:10px; color:#50665c; font-size:13px; }
.fd-create-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:8px; }
.fd-create-actions button { justify-content:center; padding:8px 12px; border:1px solid #16594f; }
.fd-create-actions button:disabled { opacity:.45; }
@media(max-width:450px) {
  .fd-type-list > div { grid-template-columns:minmax(0,1fr); }
  .fd-create form { padding:12px; gap:12px; }
}
@media(max-width:480px) {
  .fd-heading { align-items:center; flex-direction:column; text-align:center; }
}
@media(max-width:400px) {
  .fd-library { padding-inline:12px; }
  .fd-bar { padding-inline:4px; gap:2px; }
  .fd-save { flex:0 1 auto; min-width:0; overflow-wrap:anywhere; }
  .fd-rename { min-width:0; }
  .fd-settings { padding:12px; }
}
