/* Hubibù Note. Colours from resources/branding/hubibu-colors.json (key « note »): brand #e8a400, action text #8a5d00.
   Layout: phone < 760 px one pane at a time (list or note, notebooks in a drawer); tablet 760–1099 px list beside the
   note, notebooks in a drawer; computer ≥ 1100 px three columns. */
[data-suite=note]{--accent:#8a5d00;--brand:#e8a400;--tint:#fff4d6;--ink:#1d1f1a;--muted:#62665f;--paper:#fff;--line:#e8e4d8;--bg:#faf8f2;--neg:#b23a2e;--on-brand:#2b1d00;--side-w:260px;--list-w:340px}
body{background:var(--bg);min-height:100vh;display:flex;flex-direction:column;color:var(--ink)}
body[data-size=small] .note-html{font-size:14px}
body[data-size=large] .note-html{font-size:19px}
.note-header{padding-left:max(16px,env(safe-area-inset-left));padding-right:max(16px,env(safe-area-inset-right))}
#lang{min-height:36px;padding:4px 8px;border-radius:8px}
.note-main{width:100%;flex:1;box-sizing:border-box;display:flex;flex-direction:column;min-height:0}
.note-footer{justify-content:center;text-align:center;color:var(--muted);font-size:12px;padding:10px!important;margin-top:0!important}
.note-footer span{margin:0!important}
h1{font-size:22px;line-height:1.2;margin:0}
h2{font-size:18px;margin:0}
.muted{color:var(--muted)}
.small{font-size:12px}
.grow{flex:1;min-width:0}
.label{font-size:11px;text-transform:uppercase;letter-spacing:.07em;color:var(--muted);margin:16px 0 6px;font-weight:600}
.narrow{max-width:560px;margin:24px auto;padding:0 16px;box-sizing:border-box;width:100%}
.stack{display:grid;gap:12px}
.row-form{display:flex;gap:10px;align-items:end;flex-wrap:wrap}
input,select{min-height:44px;font-size:16px;border-radius:10px;box-sizing:border-box;max-width:100%}
label>span{font-size:12px;color:var(--muted)}
.command{border-radius:12px;min-height:46px;font-size:15px;background:var(--brand);border:1px solid var(--brand);color:var(--on-brand);font-weight:700;cursor:pointer;padding:0 16px}
.ghost{background:var(--paper);border:1px solid var(--line);border-radius:10px;padding:8px 14px;min-height:44px;cursor:pointer;color:var(--accent);font-weight:600;font:inherit}
.ghost.small{min-height:34px;padding:4px 10px;font-size:13px}
.link{background:none;border:0;color:var(--accent);cursor:pointer;font:inherit;padding:6px;min-height:36px}
.danger{color:var(--neg)!important}
.icon-button{background:none;border:0;border-radius:10px;min-width:40px;min-height:40px;font-size:18px;cursor:pointer;color:var(--ink);display:inline-grid;place-items:center}
.icon-button:hover{background:var(--tint)}
.icon-button.small{min-width:30px;min-height:30px;font-size:14px}
.icon-button[aria-pressed=true]{background:var(--tint)}
#notice:empty{display:none}
#notice{margin:8px 16px 0;padding:10px 14px;border-radius:10px;background:var(--tint);font-size:14px}
#notice.error{background:#fbe5e2;color:var(--neg)}
.error-text{color:var(--neg)}
.empty{color:var(--muted);text-align:center;padding:32px 12px}
.hero-tile{display:block;margin:0 auto 12px;border-radius:20px}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}

/* Workspace */
.note-workspace{flex:1;display:grid;grid-template-columns:var(--side-w) var(--list-w) minmax(0,1fr);min-height:0;height:calc(100vh - 110px);height:calc(100dvh - 110px)}
.side{background:var(--paper);border-right:1px solid var(--line);padding:14px 12px;overflow:auto;display:flex;flex-direction:column;gap:6px}
.side>.command{width:100%;margin-bottom:6px}
.side-nav{display:grid;gap:2px}
.side-nav button,.side-item{display:flex;align-items:center;gap:10px;width:100%;text-align:left;background:none;border:0;border-radius:10px;padding:8px 10px;min-height:40px;font:inherit;color:var(--ink);cursor:pointer}
.side-nav button:hover{background:var(--bg)}
.side-nav button[aria-current=true]{background:var(--tint);font-weight:600}
.side-nav b{margin-left:auto;font-weight:500;color:var(--muted);font-size:12px}
.side-nav button>span:nth-child(2){flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.side-head{display:flex;align-items:center;justify-content:space-between}
.side-head .label{margin-bottom:6px}
.notebook-row{display:flex;align-items:center}
.notebook-row .side-item{flex:1;min-width:0}
.notebook-row .icon-button{opacity:.5}
.notebook-row:hover .icon-button{opacity:1}
.dot{width:22px;height:22px;border-radius:7px;display:inline-grid;place-items:center;font-size:12px;flex:none;color:#fff}
.tag-cloud{display:flex;flex-wrap:wrap;gap:6px}
.tag{border:1px solid var(--line);background:var(--paper);border-radius:999px;padding:4px 10px;font:inherit;font-size:13px;cursor:pointer;color:var(--accent)}
.tag small{margin-left:4px;color:var(--muted)}
.tag[aria-current=true]{background:var(--tint);border-color:var(--brand)}
.side-foot{margin-top:auto;display:grid;gap:8px;padding-top:16px}
.side-foot .ghost{text-align:left}
.usage{display:grid;gap:4px}
.usage .bar{height:6px;background:var(--line);border-radius:3px;overflow:hidden}
.usage i{display:block;height:100%;background:var(--brand)}
.scrim{position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:40}

.list-pane{border-right:1px solid var(--line);display:flex;flex-direction:column;min-height:0;min-width:0;position:relative}
.list-top{display:flex;gap:8px;padding:12px 12px 6px;align-items:center}
.list-top input{flex:1;min-width:0}
#menuButton{display:none}
.list-head{display:flex;align-items:center;gap:8px;padding:6px 14px 8px;justify-content:space-between}
.list-head h1{font-size:18px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.list-head select{min-height:34px;font-size:13px;max-width:48%}
.note-list{overflow:auto;padding:0 10px 90px;display:grid;gap:6px;align-content:start;flex:1}
.note-card{display:grid;gap:4px;text-align:left;width:100%;background:var(--paper);border:1px solid var(--line);border-radius:12px;padding:10px 12px;font:inherit;color:var(--ink);cursor:pointer}
.note-card[aria-current=true]{border-color:var(--brand);box-shadow:0 0 0 2px var(--tint)}
.note-card-head{display:flex;gap:6px;align-items:baseline}
.note-card-head b{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.note-card-preview{color:var(--muted);font-size:13px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.note-card-meta{display:flex;gap:4px;flex-wrap:wrap}
.chip{font-size:11px;border-radius:999px;padding:2px 8px;background:var(--bg);border:1px solid var(--line);color:var(--muted)}
.chip[style]{border-color:var(--chip);color:var(--ink)}
body[data-density=compact] .note-card{padding:6px 10px;gap:2px}
body[data-density=compact] .note-card-meta{display:none}
.trash-card{cursor:default}
.trash-card .ghost{justify-self:start}
.todo-group{background:var(--paper);border:1px solid var(--line);border-radius:12px;padding:8px 12px}
.todo-note{font-weight:700;padding:4px 0}
.todo{display:flex;gap:10px;align-items:center;min-height:36px}
.todo input{min-height:0;width:20px;height:20px;accent-color:var(--brand)}
.fab{position:absolute;right:16px;bottom:16px;width:56px;height:56px;border-radius:50%;font-size:28px;padding:0;display:none;box-shadow:0 6px 18px rgba(0,0,0,.18)}

.editor-pane{min-width:0;min-height:0;overflow:auto;background:var(--paper)}
.editor-empty{display:grid;place-items:center;height:100%}
.editor{max-width:820px;margin:0 auto;padding:10px 24px 80px;position:relative}
.editor-top{display:flex;align-items:center;gap:6px;position:sticky;top:0;background:var(--paper);padding:6px 0;z-index:5}
#backButton{display:none;font-size:26px}
#noteNotebook{min-height:36px;font-size:14px;max-width:40%}
.save-state{flex:1;font-size:12px;color:var(--muted);text-align:right;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.save-state.error{color:var(--neg)}
.menu{position:relative}
.menu>summary{list-style:none}
.menu>summary::-webkit-details-marker{display:none}
.menu-panel{position:absolute;right:0;top:44px;background:var(--paper);border:1px solid var(--line);border-radius:12px;box-shadow:0 10px 30px rgba(0,0,0,.12);padding:6px;display:grid;min-width:250px;z-index:20}
.menu-panel button{background:none;border:0;text-align:left;padding:10px 12px;border-radius:8px;font:inherit;cursor:pointer;color:var(--ink)}
.menu-panel button:hover{background:var(--bg)}
.note-title{width:100%;border:0;font-size:26px;font-weight:700;padding:8px 0;background:none;outline:none;color:var(--ink)}
.toolbar{display:flex;flex-wrap:wrap;gap:2px;padding:4px 0 8px;border-bottom:1px solid var(--line);position:sticky;top:52px;background:var(--paper);z-index:4}
.tool{background:none;border:0;border-radius:8px;min-width:34px;min-height:34px;font:inherit;font-weight:700;cursor:pointer;color:var(--ink)}
.tool:hover{background:var(--tint)}
.tool-italic{font-style:italic}.tool-underline{text-decoration:underline}.tool-strike{text-decoration:line-through}
.tool-gap{width:1px;background:var(--line);margin:4px 4px}
.note-body{min-height:50vh;outline:none;padding:12px 0}
.note-html{font-size:16px;line-height:1.6;overflow-wrap:anywhere}
.note-html h1{font-size:1.6em;margin:.8em 0 .3em}.note-html h2{font-size:1.3em;margin:.8em 0 .3em}.note-html h3{font-size:1.1em;margin:.8em 0 .3em}
.note-html p{margin:.3em 0}
.note-html blockquote{border-left:3px solid var(--brand);margin:.5em 0;padding:.2em 0 .2em 12px;color:var(--muted)}
.note-html pre{background:var(--bg);border-radius:8px;padding:10px 12px;overflow:auto;font-size:.9em}
.note-html code{background:var(--bg);border-radius:4px;padding:0 4px;font-size:.92em}
.note-html mark{background:#ffe58a;border-radius:3px;padding:0 2px}
.note-html a{color:var(--accent)}
.note-html img{max-width:100%;height:auto;border-radius:8px;display:block;margin:8px 0}
.note-html table{border-collapse:collapse;width:100%;margin:8px 0;display:block;overflow-x:auto}
.note-html th,.note-html td{border:1px solid var(--line);padding:6px 8px;min-width:60px;text-align:left;vertical-align:top}
.note-html th{background:var(--bg)}
.note-html hr{border:0;border-top:1px solid var(--line);margin:16px 0}
.note-html ul[data-type=checklist]{list-style:none;padding-left:0}
.note-html ul[data-type=checklist]>li{position:relative;padding-left:30px;min-height:28px}
.note-html ul[data-type=checklist]>li::before{content:"";position:absolute;left:2px;top:4px;width:18px;height:18px;border:2px solid var(--accent);border-radius:5px;box-sizing:border-box;cursor:pointer;background:var(--paper)}
.note-html ul[data-type=checklist]>li[data-checked=true]::before{background:var(--brand);border-color:var(--brand)}
.note-html ul[data-type=checklist]>li[data-checked=true]::after{content:"✓";position:absolute;left:6px;top:0;font-weight:700;color:var(--on-brand);font-size:14px;pointer-events:none}
.note-html ul[data-type=checklist]>li[data-checked=true]{color:var(--muted);text-decoration:line-through}
.slash-menu{position:absolute;z-index:30;background:var(--paper);border:1px solid var(--line);border-radius:12px;box-shadow:0 10px 30px rgba(0,0,0,.14);padding:6px;display:grid;width:240px;max-height:300px;overflow:auto}
.slash-menu button{display:flex;gap:10px;align-items:center;background:none;border:0;border-radius:8px;padding:8px;font:inherit;cursor:pointer;text-align:left;color:var(--ink)}
.slash-menu button[aria-selected=true]{background:var(--tint)}
.slash-icon{width:28px;height:28px;border-radius:7px;background:var(--bg);display:inline-grid;place-items:center;font-weight:700;font-size:12px}
.attachments,.link-list{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}
.attachment,.link-chip{display:inline-flex;align-items:center;gap:4px;background:var(--bg);border:1px solid var(--line);border-radius:10px;padding:4px 6px 4px 10px;font-size:13px}
.attachment a,.link-chip a{color:var(--accent);text-decoration:none}
.link-chip{background:var(--tint);border-color:#f2d58a}
.tags-field{display:flex;align-items:center;gap:6px;margin-top:14px;color:var(--muted)}
.tags-field input{flex:1;border:0;border-bottom:1px solid var(--line);border-radius:0;background:none;min-height:36px;font-size:14px}

/* Dialogs */
.sheet{border:0;border-radius:18px;padding:18px;width:min(520px,calc(100vw - 32px));box-sizing:border-box;max-height:calc(100dvh - 32px)}
.sheet.wide{width:min(980px,calc(100vw - 32px))}
.sheet::backdrop{background:rgba(0,0,0,.35)}
.sheet-head{display:flex;justify-content:space-between;align-items:center;gap:8px}
.sheet-actions{display:flex;justify-content:flex-end;gap:8px;flex-wrap:wrap}
.switch{display:flex;gap:10px;align-items:center}
.switch input{min-height:0;width:20px;height:20px;accent-color:var(--brand);flex:none}
.switch span{font-size:14px;color:var(--ink)}
.file-button{display:inline-flex;align-items:center;justify-content:center;cursor:pointer}
.howto ul{padding-left:18px;font-size:14px;display:grid;gap:4px}
.import-preview{background:var(--bg);border-radius:12px;padding:12px;font-size:14px;max-height:40vh;overflow:auto}
.history{display:grid;grid-template-columns:240px minmax(0,1fr);gap:12px;min-height:50vh}
.history-list{display:grid;gap:4px;align-content:start;overflow:auto;max-height:65vh}
.history-item{display:grid;text-align:left;background:none;border:1px solid var(--line);border-radius:10px;padding:8px 10px;font:inherit;cursor:pointer}
.history-item[aria-current=true]{border-color:var(--brand);background:var(--tint)}
.history-view{overflow:auto;max-height:65vh;display:grid;gap:10px;align-content:start}
.emoji-field input{width:70px;text-align:center}
.colors{border:0;padding:0;margin:0}
.color-row{display:flex;gap:8px;flex-wrap:wrap}
.swatch{width:32px;height:32px;border-radius:50%;background:var(--swatch);display:inline-grid;place-items:center;cursor:pointer}
.swatch input{appearance:none;margin:0;min-height:0;width:32px;height:32px;border-radius:50%;cursor:pointer}
.swatch input:checked{box-shadow:0 0 0 3px var(--paper) inset,0 0 0 2px var(--ink)}

/* Public note */
.public-note{background:var(--paper);border:1px solid var(--line);border-radius:18px;padding:20px}
.public-note h1{font-size:26px}
.badge{display:inline-flex;gap:8px;align-items:center;margin:16px auto;padding:8px 14px;border-radius:999px;background:var(--tint);color:var(--accent);text-decoration:none;font-weight:600;font-size:13px}
#public{text-align:left}
#public .badge{display:flex;width:max-content}
#public .badge[hidden]{display:none}

/* Tablet: notebooks in a drawer, list beside the note */
@media (max-width:1099px){
  .note-workspace{grid-template-columns:var(--list-w) minmax(0,1fr)}
  .side{position:fixed;left:0;top:0;bottom:0;width:min(300px,85vw);z-index:50;transform:translateX(-105%);transition:transform .2s;box-shadow:0 0 30px rgba(0,0,0,.2);padding-top:max(14px,env(safe-area-inset-top))}
  .note-workspace[data-side=open] .side{transform:none}
  #menuButton{display:inline-grid}
}
/* Phone: one pane at a time */
@media (max-width:759px){
  .note-workspace{grid-template-columns:minmax(0,1fr);height:auto;min-height:calc(100dvh - 110px)}
  .note-workspace[data-pane=list] .editor-pane{display:none}
  .note-workspace[data-pane=editor] .list-pane{display:none}
  .list-pane{border-right:0}
  .note-list{overflow:visible}
  .fab{display:grid;place-items:center;position:fixed;right:max(16px,env(safe-area-inset-right));bottom:max(16px,env(safe-area-inset-bottom))}
  .editor{padding:6px 14px 80px}
  #backButton{display:inline-grid}
  .toolbar{flex-wrap:nowrap;overflow-x:auto;top:52px}
  .tool{flex:none}
  .note-title{font-size:22px}
  .history{grid-template-columns:1fr}
  .history-list{max-height:30vh}
  .note-footer{display:none!important}
  .sheet{margin-bottom:0;border-radius:18px 18px 0 0;width:100vw;max-width:100vw}
}
@media (prefers-reduced-motion:reduce){.side{transition:none}}
.side-nav .icon-button{width:auto;flex:none;padding:0;justify-content:center}
