:root{
  --font-scale:1.08;
  --paper:#f7f3ed;
  --panel:#fffdfa;
  --sidebar:#f1ece5;
  --ink:#252321;
  --muted:#817b73;
  --line:#e5ddd2;
  --accent:#b85d48;
  --accent-soft:#efe2d7;
  --mine:#efe2d7;
  --green:#68836d;

  /* Muted semantic accents — Studio's base palette remains unchanged */
  --task-bg:#f3f7f3;
  --task-line:#b9c7bb;
  --task-ink:#4e6753;

  --decision-bg:#f4f1f9;
  --decision-line:#c8c1d8;
  --decision-ink:#625a78;

  --project-bg:#fbf7ee;
  --project-line:#d5c4a2;
  --project-ink:#7c6541;

  --pin-bg:#fbf3ef;
  --pin-line:#d9c2b7;
  --pin-ink:#765448;

  --reminder-bg:#f2f6f8;
  --reminder-line:#bdcbd2;
  --reminder-ink:#526875;

  --shadow:0 8px 30px rgba(58,45,35,.08);
}
*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;background:#e9e4dd;color:var(--ink);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
button,input,textarea,select{font:inherit}
button{color:inherit}
.hidden{display:none!important}

.auth-loading-screen{
  min-height:100dvh;
  display:grid;
  place-items:center;
  padding:22px;
  background:var(--paper);
}
.auth-loading-card{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:15px;
  color:var(--muted);
}
.auth-loading-card .login-brand{margin:0;color:var(--ink)}
.auth-loading-row{display:flex;align-items:center;gap:9px;font-size:13px}
.auth-spinner{
  width:15px;height:15px;border-radius:50%;
  border:2px solid var(--line);
  border-top-color:var(--accent);
  animation:studio-spin .75s linear infinite;
}
@keyframes studio-spin{to{transform:rotate(360deg)}}

.login-screen{min-height:100dvh;display:grid;place-items:center;padding:22px;background:var(--paper)}
.login-card{width:min(420px,100%);background:#fff;border:1px solid var(--line);border-radius:22px;padding:30px;box-shadow:var(--shadow)}
.login-brand{font:italic 34px Georgia,serif;margin-bottom:8px}
.login-card>p{color:var(--muted);margin:0 0 24px}
.login-card label,.sheet label{display:block;color:#665f58;font-size:13px;margin:13px 0}
.login-card input,.sheet input,.sheet select{width:100%;border:1px solid var(--line);border-radius:11px;padding:12px;background:#fff;margin-top:6px;outline:none}
.primary{border:0;border-radius:12px;background:var(--accent);color:#fff;padding:11px 15px;cursor:pointer;font-weight:650}
.login-card .primary{width:100%;margin-top:10px}
.login-error{color:#a14c3d;font-size:12px;margin-top:12px;min-height:16px}

.app-shell{max-width:1180px;height:100dvh;margin:auto;background:var(--paper);display:grid;grid-template-columns:230px 1fr;box-shadow:var(--shadow);overflow:hidden}
.sidebar{background:var(--sidebar);border-right:1px solid var(--line);padding:25px 17px;display:flex;flex-direction:column;z-index:20}
.brand{font:italic 29px Georgia,serif;margin:0 0 28px 8px}
.nav{display:flex;flex-direction:column;gap:2px}
.nav button{border:0;background:transparent;border-radius:12px;padding:11px 12px;display:flex;align-items:center;gap:10px;text-align:left;cursor:pointer;color:#625d57;font-size:15px}
.nav button svg{width:17px;height:17px;stroke-width:1.8;flex:0 0 auto}
.nav button.active{background:#fff;color:var(--ink);box-shadow:0 2px 10px rgba(0,0,0,.035)}
.nav .count{margin-left:auto;background:#e5d2c3;border-radius:99px;min-width:20px;padding:1px 6px;text-align:center;font-size:11px}
.nav .count:empty{display:none}
.sidebar-footer{margin-top:auto;border-top:1px solid var(--line);padding:15px 8px 0;color:var(--muted);font-size:11px}
.sidebar-footer span{display:block;margin-bottom:8px;overflow:hidden;text-overflow:ellipsis}
.sidebar-footer .studio-version{font-size:10px;letter-spacing:.02em;opacity:.72;margin-top:-2px}
.sidebar-footer button{border:0;background:transparent;padding:0;display:flex;gap:6px;align-items:center;color:#746d65;cursor:pointer;font-size:11px}
.sidebar-footer svg{width:13px;height:13px}
.sidebar-backdrop{display:none}

.main{position:relative;display:flex;flex-direction:column;min-width:0;height:100dvh}
.topbar{height:72px;flex:0 0 72px;display:flex;justify-content:space-between;align-items:center;padding:0 22px;border-bottom:1px solid var(--line);background:rgba(255,253,250,.86);backdrop-filter:blur(12px);z-index:8}
.topbar-left,.topbar-actions{display:flex;align-items:center;gap:10px}
.topbar h1{font-size:17px;margin:0}
.topbar p{font-size:12px;color:var(--muted);margin:3px 0 0}
.icon-control,.text-control{border:0;background:#f1ece5;border-radius:10px;width:38px;height:38px;display:grid;place-items:center;cursor:pointer}
.icon-control svg{width:18px;height:18px;stroke-width:1.8}
.text-control{font-weight:700}
.font-wrap{position:relative}
.font-menu{display:none;position:absolute;right:0;top:45px;background:#fff;border:1px solid var(--line);border-radius:12px;padding:6px;box-shadow:var(--shadow);width:150px;z-index:30}
.font-menu.show{display:block}
.font-menu button{width:100%;border:0;background:transparent;border-radius:8px;text-align:left;padding:11px 12px;font-size:15px;cursor:pointer}
.font-menu button.active{background:#f1ece5}
.mobile-only{display:none}

.view{display:none;flex:1;overflow:auto}
.view.active{display:flex}
.chat-view{flex-direction:column;padding:18px 22px 128px}
.generic-view{flex-direction:column;padding:24px 25px 48px}
.section-heading h2{font:25px Georgia,serif;margin:0 0 5px}
.section-heading p{color:var(--muted);font-size:13px;margin:0 0 19px}

.message-list{display:flex;flex-direction:column}
.day-divider{text-align:center;color:#999;font-size:10px;margin:10px 0 18px}
.message-row{display:flex;margin:6px 0;scroll-margin:100px}
.message-row.mine{justify-content:flex-end}
.message{position:relative;max-width:73%;border:1px solid var(--line);background:#fff;border-radius:18px 18px 18px 5px;padding:10px 12px;box-shadow:0 2px 8px rgba(0,0,0,.022)}
.mine .message{background:var(--mine);border-color:#e2d0c1;border-radius:18px 18px 5px 18px}
.sender{font-size:10px;font-weight:700;color:var(--accent);margin-bottom:4px}
.mine .sender{display:none}
.message-text{font-size:calc(15px * var(--font-scale));line-height:1.43;white-space:pre-wrap;overflow-wrap:anywhere}
.message-meta{font-size:10px;color:#999;text-align:right;margin-top:5px}
.reply-quote{border-left:3px solid #cfb6a3;padding-left:8px;margin-bottom:8px;color:#746b63;font-size:12px;line-height:1.35}
.chips{display:flex;flex-wrap:wrap;gap:4px;margin-top:7px}
.chip{display:inline-flex;align-items:center;gap:4px;border:1px solid #d7c5b6;border-radius:9px;padding:3px 7px;background:#fff8f2;font-size:10px;color:#695f56}
.chip svg{width:11px;height:11px;stroke-width:1.8}
.chip.task{background:var(--task-bg);border-color:var(--task-line);color:var(--task-ink)}
.chip.decision{background:var(--decision-bg);border-color:var(--decision-line);color:var(--decision-ink)}
.chip.project{background:var(--project-bg);border-color:var(--project-line);color:var(--project-ink)}
.chip.pin{background:var(--pin-bg);border-color:var(--pin-line);color:var(--pin-ink)}
.chip.reminder{background:var(--reminder-bg);border-color:var(--reminder-line);color:var(--reminder-ink)}
.message-controls{display:flex;align-items:center;gap:9px;margin-top:7px}
.message-controls button{border:0;background:transparent;color:#837a72;font-size:10px;padding:1px;display:inline-flex;align-items:center;gap:4px;cursor:pointer}
.message-controls svg{width:12px;height:12px;stroke-width:1.8}
.message-controls button.starred{color:rgb(172,98,77)}
.message-controls button.starred svg{fill:currentColor;stroke:currentColor}

.message-reactions{
  position:absolute;
  right:12px;
  top:-18px;
  left:auto;
  bottom:auto;
  display:flex;
  flex-wrap:wrap;
  gap:4px;
  margin:0;
  z-index:5;
}
.mine .message-reactions{
  right:12px;
  left:auto;
}
.message-reaction-pill{
  border:1px solid #d39a89;
  background:#faeee9;
  color:var(--ink);
  border-radius:999px;
  min-height:24px;
  padding:1px 6px;
  display:inline-flex;
  align-items:center;
  gap:3px;
  cursor:pointer;
  font-size:16px;
  line-height:1;
  box-shadow:0 1px 4px rgba(94,54,43,.10);
}
.message-reaction-pill small{
  font-size:10px;
  font-weight:600;
  color:#80665d;
  line-height:1;
}
.message-reaction-pill.mine{
  border-color:#cc8f7d;
  background:#f8e8e2;
}
.message:has(.message-reactions){margin-top:18px}

.reaction-picker{
  position:fixed;
  z-index:90;
  display:flex;
  align-items:center;
  gap:3px;
  padding:7px;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--panel);
  box-shadow:0 12px 32px rgba(45,35,30,.20);
  max-width:calc(100vw - 20px);
}
.reaction-picker.hidden{display:none}
.reaction-picker button{
  width:39px;
  height:39px;
  border:0;
  border-radius:11px;
  background:transparent;
  display:grid;
  place-items:center;
  cursor:pointer;
  font-size:23px;
  line-height:1;
  padding:0;
}
.reaction-picker button:hover,.reaction-picker button.active{
  background:#f1ece5;
  transform:scale(1.06);
}
.attachment-block{margin-top:8px;border:1px solid #dfd5ca;border-radius:12px;overflow:hidden;background:rgba(255,255,255,.62)}
.attachment-image{display:block;max-width:100%;max-height:340px;object-fit:contain;background:#eee8e1;cursor:pointer}
.attachment-file{display:flex;align-items:center;gap:9px;padding:10px;cursor:pointer}
.attachment-file svg{width:20px;height:20px;stroke-width:1.6}
.attachment-file-info{min-width:0}
.attachment-file-info strong{display:block;font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.attachment-file-info span{display:block;color:var(--muted);font-size:10px;margin-top:2px}

.reminder-banner{border:1px solid var(--reminder-line);background:var(--reminder-bg);color:var(--reminder-ink);border-radius:12px;padding:10px 12px;font-size:12px;margin-bottom:12px}

.composer{position:absolute;left:0;right:0;bottom:0;padding:12px 19px calc(12px + env(safe-area-inset-bottom));background:linear-gradient(transparent,var(--paper) 18%);z-index:7}
.compose-box{border:1px solid var(--line);background:#fff;border-radius:18px;padding:8px;display:flex;align-items:flex-end;gap:4px;box-shadow:0 7px 24px rgba(62,48,38,.08)}
.compose-box textarea{flex:1;resize:none;border:0;outline:0;background:transparent;padding:9px;min-height:38px;max-height:110px;font-size:calc(16px * var(--font-scale));line-height:1.35}
.send-btn{width:38px;height:38px;border:0;border-radius:12px;background:var(--accent);color:#fff;display:grid;place-items:center;cursor:pointer}
.send-btn svg{width:18px;height:18px}
.reply-bar{margin:0 7px -3px;padding:8px 10px 10px;background:#fff;border:1px solid var(--line);border-bottom:0;border-radius:12px 12px 0 0;display:flex;justify-content:space-between;gap:10px;align-items:center}
.reply-bar div{min-width:0}
.reply-bar strong{display:block;font-size:10px;color:var(--accent)}
.reply-bar span{display:block;font-size:11px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.reply-bar button{border:0;background:transparent;cursor:pointer}
.reply-bar svg{width:15px;height:15px}

.filter-row{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:15px}
.filter-row.compact{margin-bottom:0}
.pill{border:1px solid var(--line);background:#fff;border-radius:99px;padding:7px 10px;cursor:pointer;font-size:12px;display:inline-flex;align-items:center;gap:5px}
.pill svg{width:12px;height:12px}
.pill.active{background:#eee7df;border-color:#d4c5b7}

.card-list,.file-list{display:flex;flex-direction:column;gap:9px}
.info-card{border:1px solid var(--line);background:#fff;border-radius:14px;padding:13px;display:flex;align-items:flex-start;gap:11px}
.info-card .main-copy{min-width:0;flex:1}
.info-card .title{font-size:calc(14px * var(--font-scale));line-height:1.4}
.info-card .meta{font-size:10px;color:var(--muted);margin-top:5px}
.info-card .actions{display:flex;gap:5px;flex-wrap:wrap;margin-top:9px}
.info-card button,.secondary,.quiet-danger{border:0;background:#f1ece5;border-radius:9px;padding:7px 9px;font-size:11px;display:inline-flex;align-items:center;gap:5px;cursor:pointer}
.info-card button svg,.secondary svg,.quiet-danger svg{width:13px;height:13px}
.task-check{width:21px;height:21px;border:2px solid #9bae9e;border-radius:7px;flex:0 0 auto;cursor:pointer;margin-top:calc(9.8px * var(--font-scale) - 10.5px)}
.info-card.done{opacity:.56}
.info-card.done .task-check{background:var(--green)}
.info-card.done .title{text-decoration:line-through}

.task-item{position:relative}
.info-card .task-drag{
  width:36px;height:42px;flex:0 0 36px;
  margin:-6px -3px -6px -6px;padding:0;
  border:0;background:transparent;color:#aaa;
  display:grid;place-items:center;cursor:grab;touch-action:none;
}
.info-card .task-drag:hover{background:transparent}
.info-card .task-drag svg{width:16px;height:16px;stroke-width:1.8}
.info-card .task-drag.disabled{opacity:.3;cursor:default}
.task-item.dragging{
  opacity:.94;transform:scale(1.008);
  box-shadow:0 13px 30px rgba(0,0,0,.13);
  pointer-events:none;z-index:3;
}
.task-drag-active{user-select:none;-webkit-user-select:none}
.task-drag-active .task-drag{cursor:grabbing}

.project-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:10px}
.project-card{border:1px solid var(--project-line);background:linear-gradient(135deg,#fff 72%,var(--project-bg));border-radius:14px;padding:14px;cursor:pointer}
.project-card strong{font-size:14px}
.project-card span{display:block;color:var(--muted);font-size:11px;margin-top:5px}

.file-card{border:1px solid var(--line);background:#fff;border-radius:14px;padding:11px;display:grid;grid-template-columns:88px minmax(0,1fr) auto;align-items:center;gap:12px}
.file-preview-trigger{border:0!important;background:transparent!important;padding:0!important;border-radius:11px!important;display:block!important;width:88px;height:68px;overflow:hidden;cursor:pointer}
.file-thumb{width:88px;height:68px;border:1px solid var(--line);border-radius:11px;overflow:hidden;background:#f1ece5;display:grid;place-items:center;position:relative}
.file-thumb-placeholder{display:grid;place-items:center;color:#756d65}
.file-thumb-placeholder svg{width:24px!important;height:24px!important;stroke-width:1.6}
.file-thumb-image{display:block;width:100%;height:100%;object-fit:cover}
.file-thumb-pdf{display:block;width:145%;height:145%;border:0;pointer-events:none;transform:scale(.70);transform-origin:top left;background:#fff}
.file-preview-trigger.previewable:hover .file-thumb{box-shadow:0 0 0 2px rgba(184,93,72,.16)}
.file-copy{min-width:0}
.file-copy strong{display:block;font-size:calc(13px * var(--font-scale));white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.file-copy span{display:block;color:var(--muted);font-size:10px;margin-top:3px}
.file-chat-btn{border:0;background:#f1ece5;border-radius:9px;padding:7px 9px;font-size:10px;display:inline-flex;align-items:center;gap:5px;cursor:pointer;white-space:nowrap}
.file-chat-btn svg{width:12px;height:12px}

.file-preview-sheet{width:min(900px,calc(100vw - 30px))}
.file-preview-content{min-height:280px;max-height:68dvh;border:1px solid var(--line);border-radius:14px;background:#f3eee8;overflow:hidden;display:grid;place-items:center;margin:14px 0}
.file-preview-image{display:block;max-width:100%;max-height:68dvh;object-fit:contain}
.file-preview-pdf{display:block;width:100%;height:68dvh;min-height:500px;border:0;background:#fff}
.file-preview-placeholder{min-height:280px;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:9px;padding:24px;color:var(--muted)}
.file-preview-placeholder svg{width:42px;height:42px;stroke-width:1.4}
.file-preview-placeholder strong{color:var(--ink);font-size:14px;max-width:90%;overflow-wrap:anywhere}
.file-preview-placeholder span{font-size:12px}
.file-preview-actions{display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap}

.scratch-toolbar{display:flex;justify-content:space-between;gap:10px;align-items:center;margin-bottom:13px}
.scratch-toolbar-left{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.secondary{border:1px solid var(--line);background:#fff}
.save-state{font-size:10px;color:var(--muted)}
.scratch-layout{display:grid;grid-template-columns:225px 1fr;gap:13px;min-height:390px}
.note-list{display:flex;flex-direction:column;gap:7px}
.note-item{position:relative;border:1px solid var(--line);background:#fff;border-radius:12px;padding:7px 9px 7px 5px;display:grid;grid-template-columns:38px minmax(0,1fr) 30px;align-items:center;gap:6px;cursor:pointer;text-align:left}
.note-item.active{background:#f1ece5}
.note-drag{width:38px;height:42px;display:grid;place-items:center;color:#aaa;touch-action:none;cursor:grab}
.note-drag svg{width:15px;height:15px}
.note-item-copy{min-width:0}
.note-item-copy strong{display:block;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.note-item-copy span{display:block;font-size:10px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:3px}
.note-star{display:grid;place-items:center;color:#aaa}
.note-star svg{width:15px;height:15px}
.note-star.starred{color:#8a7252}
.note-star.starred svg{fill:currentColor}
.note-item.dragging{opacity:.94;transform:scale(1.008);box-shadow:0 13px 30px rgba(0,0,0,.13);pointer-events:none;z-index:3}
.note-drag-active{user-select:none;-webkit-user-select:none}
.note-drag-active .note-drag{cursor:grabbing}

.note-item.drop-before::before,.task-item.drop-before::before,
.note-item.drop-after::after,.task-item.drop-after::after{
  content:"";position:absolute;left:8px;right:8px;height:3px;
  border-radius:999px;background:var(--accent);
  box-shadow:0 0 0 2px var(--paper);z-index:6;pointer-events:none;
}
.note-item.drop-before::before,.task-item.drop-before::before{top:-6px}
.note-item.drop-after::after,.task-item.drop-after::after{bottom:-6px}
.note-editor{border:1px solid var(--line);background:#fff;border-radius:14px;padding:14px;display:flex;flex-direction:column;min-width:0}
.note-title-row{display:flex;align-items:center;border-bottom:1px solid var(--line)}
.note-title{flex:1;border:0;outline:0;padding:4px 2px 10px;font-size:calc(18px * var(--font-scale));font-weight:650;background:transparent;min-width:0}
.star-control{border:0;background:transparent;color:#aaa;cursor:pointer;padding:7px}
.star-control svg{width:17px;height:17px}
.star-control.starred{color:#8a7252}
.star-control.starred svg{fill:currentColor}
.note-formatbar{display:flex;align-items:center;gap:5px;padding:8px 0;border-bottom:1px solid var(--line);flex-wrap:wrap}
.note-formatgroup{display:flex;align-items:center;gap:3px}
.note-format-divider{width:1px;height:22px;background:var(--line);margin:0 2px}
.note-formatbar button{width:32px;height:30px;border:0;background:transparent;border-radius:7px;display:grid;place-items:center;cursor:pointer;color:var(--muted);font-size:13px}
.note-formatbar button.format-text-button{font-size:11px;font-weight:700;letter-spacing:-.02em}
.note-formatbar button:hover,.note-formatbar button.active{background:#f1ece5}
.note-formatbar button:disabled{opacity:.35;cursor:default;background:transparent}
.note-formatbar button svg{width:15px;height:15px;stroke-width:1.8}
.note-body{flex:1;min-height:275px;border:0;outline:0;padding:13px 2px;background:transparent;font-size:calc(15px * var(--font-scale));line-height:1.5;overflow:auto;white-space:normal}
.note-body:empty:before{content:attr(data-placeholder);color:#aaa;pointer-events:none}
.note-body p{margin:.2em 0 .8em}
.note-body div{margin:.15em 0}
.note-body h1{font-size:1.55em;line-height:1.2;margin:.55em 0 .35em;font-weight:700;letter-spacing:-.018em}
.note-body h2{font-size:1.22em;line-height:1.28;margin:.7em 0 .35em;font-weight:680;letter-spacing:-.01em}
.note-body ul,.note-body ol{margin:.35em 0 .8em;padding-left:3.1em}
.note-body li{position:relative;margin:.18em 0;padding-left:.08em;min-height:1.55em}
.note-body mark{background:#fff0a8}
.note-body .list-drag-handle{position:absolute;left:-3em;top:.03em;width:1.5em;height:1.65em;display:grid;place-items:center;border-radius:6px;color:var(--muted);opacity:.42;cursor:grab;touch-action:none;user-select:none;-webkit-user-select:none}
@media (hover:hover) and (pointer:fine){
  .note-body .list-drag-handle:hover{opacity:.8;background:transparent}
}
.note-body .list-drag-handle:focus,.note-body .list-drag-handle:focus-visible{background:transparent;outline:none}
.note-body .list-drag-handle:active{opacity:.86;background:transparent}
.note-body li.list-item-dragging>.list-drag-handle{opacity:.95;background:#f1ece5}
.note-body .list-drag-handle svg{width:14px;height:14px;stroke-width:1.7;pointer-events:none}
.note-body ul.checklist{list-style:none;padding-left:3.1em}
.note-body ul.checklist>li{padding-left:0}
.note-body ul.checklist>li>.list-drag-handle{left:-3em}
.note-body .check-toggle{position:absolute;left:-1.35em;top:.16em;width:1.05em;height:1.05em;border:1.5px solid #8d857d;border-radius:4px;background:transparent;cursor:pointer;display:grid;place-items:center;user-select:none;-webkit-user-select:none}
.note-body .check-toggle:focus{outline:2px solid color-mix(in srgb,var(--accent) 55%,transparent);outline-offset:2px}
.note-body ul.checklist>li[data-checked="true"]>.check-toggle{background:var(--accent);border-color:var(--accent)}
.note-body ul.checklist>li[data-checked="true"]>.check-toggle::after{content:"✓";font-size:.76em;line-height:1;color:#fff;font-weight:800}
.note-body ul.checklist>li[data-checked="true"]{color:var(--muted)}
.editor-list-drag-active{user-select:none;-webkit-user-select:none}
.editor-list-drag-active .note-body{cursor:grabbing}
.note-body li.list-item-dragging{opacity:.42}
.note-body li.list-drop-before::before,.note-body li.list-drop-after::after{content:"";position:absolute;left:-.15em;right:0;height:3px;border-radius:999px;background:var(--accent);pointer-events:none}
.note-body li.list-drop-before::before{top:-.18em}
.note-body li.list-drop-after::after{bottom:-.18em}
.note-actions{display:flex;gap:7px;border-top:1px solid var(--line);padding-top:10px}
.quiet-danger{background:transparent;color:#8e5b50}

.search-input{border:1px solid var(--line);background:#fff;border-radius:13px;padding:12px 13px;font-size:calc(16px * var(--font-scale));outline:0}
.search-results{margin-top:13px}

.guide-heading{max-width:760px}
.guide-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(270px,1fr));gap:10px}
.guide-card{
  border:1px solid var(--line);background:#fff;border-radius:15px;padding:15px;
  display:grid;grid-template-columns:38px minmax(0,1fr);gap:11px;align-items:start;
}
.guide-icon{width:38px;height:38px;border-radius:11px;display:grid;place-items:center;background:#f1ece5}
.guide-icon svg{width:18px;height:18px;stroke-width:1.8}
.guide-card h3{font-size:14px;margin:0 0 3px}
.guide-card strong{display:block;font-size:13px;margin-bottom:4px}
.guide-card p{font-size:12px;line-height:1.45;color:var(--muted);margin:0 0 7px}
.guide-card small{font-size:11px;color:var(--muted);font-style:italic}
.guide-task{border-color:var(--task-line)}
.guide-task .guide-icon{background:var(--task-bg);color:var(--task-ink)}
.guide-task strong{color:var(--task-ink)}
.guide-decision{border-color:var(--decision-line)}
.guide-decision .guide-icon{background:var(--decision-bg);color:var(--decision-ink)}
.guide-decision strong{color:var(--decision-ink)}
.guide-project{border-color:var(--project-line)}
.guide-project .guide-icon{background:var(--project-bg);color:var(--project-ink)}
.guide-project strong{color:var(--project-ink)}
.guide-pin{border-color:var(--pin-line)}
.guide-pin .guide-icon{background:var(--pin-bg);color:var(--pin-ink)}
.guide-pin strong{color:var(--pin-ink)}
.guide-reminder{border-color:var(--reminder-line)}
.guide-reminder .guide-icon{background:var(--reminder-bg);color:var(--reminder-ink)}
.guide-reminder strong{color:var(--reminder-ink)}
.guide-label .guide-icon{color:#6f665e}
.guide-star .guide-icon{color:#8a7252;background:#f7f1e8}
.guide-combine{
  margin-top:14px;border:1px dashed var(--line);border-radius:14px;padding:14px;
  display:flex;align-items:flex-start;gap:10px;color:var(--muted)
}
.guide-combine>svg{width:19px;height:19px;flex:0 0 auto;margin-top:1px;color:var(--accent)}
.guide-combine strong{display:block;color:var(--ink);font-size:13px;margin-bottom:3px}
.guide-combine p{font-size:12px;line-height:1.48;margin:0}

.search-result{padding:12px 3px;border-bottom:1px solid var(--line);cursor:pointer}
.search-result strong{font-size:calc(13px * var(--font-scale));font-weight:500}
.search-result span{display:block;color:var(--muted);font-size:10px;margin-top:4px}

.modal{display:none;position:fixed;inset:0;background:rgba(30,25,20,.28);z-index:50;align-items:flex-end;justify-content:center}

/* Message Actions: contextual popover rather than a detached bottom drawer. */
#actionsModal.contextual{
  display:block;
  background:transparent;
}
#actionsModal.contextual .sheet{
  position:fixed;
  width:min(370px,calc(100vw - 24px));
  max-height:min(72dvh,540px);
  border:1px solid var(--line);
  border-radius:17px;
  padding:15px;
  box-shadow:0 16px 42px rgba(35,28,24,.18);
}
#actionsModal.contextual .sheet h2{font-size:20px}
#actionsModal.contextual .sheet-head p{max-width:290px}
#actionsModal.contextual .action-grid{grid-template-columns:1fr 1fr;gap:7px;margin-top:12px}
#actionsModal.contextual .action-grid button{padding:11px}
.modal.show{display:flex}
.sheet{width:min(570px,100%);max-height:88dvh;overflow:auto;background:#fff;border-radius:22px 22px 0 0;padding:20px 21px calc(26px + env(safe-area-inset-bottom));box-shadow:0 -8px 30px rgba(0,0,0,.12)}
.sheet.narrow{width:min(500px,100%)}
.sheet-head{display:flex;justify-content:space-between;gap:12px;align-items:flex-start}
.sheet h2{font:24px Georgia,serif;margin:0 0 5px}
.sheet-head p{color:var(--muted);font-size:11px;line-height:1.35;margin:0;max-width:430px}
.sheet-close{border:0;background:#f1ece5;width:32px;height:32px;border-radius:9px;display:grid;place-items:center;cursor:pointer;flex:0 0 auto}
.sheet-close svg{width:15px;height:15px}
.action-grid{display:grid;grid-template-columns:1fr 1fr;gap:9px;margin-top:17px}
.action-grid button{border:1px solid var(--line);background:#faf7f2;border-radius:13px;padding:13px;text-align:left;cursor:pointer}
.action-grid strong{display:flex;align-items:center;gap:7px;font-size:13px;margin-bottom:3px}
.action-grid strong svg{width:15px;height:15px;stroke-width:1.8}
.action-grid span{display:block;color:var(--muted);font-size:10px;line-height:1.3}

/* Semantic colour is deliberately restrained: it identifies the action,
   rather than recolouring the app. */
.action-grid button[data-action="task"]{border-color:var(--task-line);background:var(--task-bg)}
.action-grid button[data-action="task"] strong{color:var(--task-ink)}
.action-grid button[data-action="pin"]{border-color:var(--pin-line);background:var(--pin-bg)}
.action-grid button[data-action="pin"] strong{color:var(--pin-ink)}
.action-grid button[data-action="reminder"]{border-color:var(--reminder-line);background:var(--reminder-bg)}
.action-grid button[data-action="reminder"] strong{color:var(--reminder-ink)}
.action-grid button[data-action="project"]{border-color:var(--project-line);background:var(--project-bg)}
.action-grid button[data-action="project"] strong{color:var(--project-ink)}
.action-grid button[data-action="decision"]{border-color:var(--decision-line);background:var(--decision-bg)}
.action-grid button[data-action="decision"] strong{color:var(--decision-ink)}

.project-picker-list{display:grid;gap:7px;margin:17px 0 11px}
.project-picker-item,.project-new-btn{
  width:100%;
  border:1px solid var(--project-line);
  background:var(--project-bg);
  border-radius:13px;
  padding:11px 12px;
  display:grid;
  grid-template-columns:30px minmax(0,1fr) auto;
  align-items:center;
  gap:9px;
  text-align:left;
  cursor:pointer;
  color:var(--project-ink);
}
.project-picker-item:hover,.project-new-btn:hover{filter:brightness(.985)}
.project-picker-item.selected{
  box-shadow:0 0 0 2px rgba(124,101,65,.12);
  background:#f9f3e7;
}
.project-picker-item.remove-project{
  border-color:var(--line);
  background:#fff;
  color:var(--muted);
  margin-top:4px;
}
.project-picker-icon{
  width:30px;height:30px;
  border-radius:9px;
  display:grid;place-items:center;
  background:rgba(255,255,255,.6)
}
.project-picker-icon svg,.project-picker-check svg,.project-new-btn svg{
  width:15px;height:15px;stroke-width:1.8
}
.project-picker-copy{min-width:0}
.project-picker-copy strong,.project-new-btn strong{
  display:block;
  color:inherit;
  font-size:12px;
  overflow:hidden;
  text-overflow:ellipsis;
}
.project-picker-copy small,.project-new-btn small{
  display:block;
  color:var(--muted);
  font-size:10px;
  margin-top:2px;
}
.project-picker-check{
  width:25px;height:25px;
  border-radius:999px;
  display:grid;place-items:center;
  background:#fff;
}
.project-new-btn{
  margin-top:8px;
  border-style:dashed;
  background:#fff;
}
.project-new-btn>svg{
  justify-self:center;
  margin-left:7px;
}
.project-new-btn span{min-width:0}
.project-picker-empty{
  border:1px dashed var(--line);
  border-radius:12px;
  padding:15px;
  color:var(--muted);
  font-size:11px;
  text-align:center;
}
.two-col{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.attachment-preview{border:1px solid var(--line);border-radius:13px;overflow:hidden;background:#f4efe9;margin:14px 0}
.attachment-preview img{display:block;width:100%;max-height:320px;object-fit:contain}
.attachment-preview .file-placeholder{min-height:120px;display:grid;place-items:center;color:#776f68}
.attachment-preview .file-placeholder svg{width:32px;height:32px}
.check-row{display:flex!important;align-items:flex-start;gap:9px;border:1px solid var(--line);border-radius:12px;padding:10px;margin:10px 0!important;cursor:pointer}
.check-row input{width:auto!important;margin:3px 0 0!important}
.check-row span{display:block}
.check-row strong{display:block;color:var(--ink);font-size:12px}
.check-row small{display:block;color:var(--muted);font-size:10px;margin-top:2px}
.optimize-estimate{font-size:10px;color:var(--muted);min-height:15px;margin:7px 0 12px}

.empty-state{color:var(--muted);text-align:center;padding:45px 15px;font-size:13px}
.toast{position:fixed;left:50%;bottom:24px;transform:translate(-50%,20px);opacity:0;pointer-events:none;background:#2e2b28;color:#fff;border-radius:10px;padding:9px 12px;font-size:11px;z-index:100;transition:.18s}
.toast.show{opacity:1;transform:translate(-50%,0)}


@media(max-width:1024px){
  /* Interface typography has a readable floor independent of the Aa reading size. */
  .topbar h1{font-size:22px}
  .topbar p{font-size:16px}
  .section-heading h2{font-size:31px}
  .section-heading p{font-size:17px;line-height:1.45}
  .day-divider{font-size:14px}
  .sender{font-size:14px}
  .message-meta{font-size:14px}
  .message-controls{gap:14px;margin-top:10px}
  .message-controls button{font-size:15px;padding:5px 1px}
  .message-controls svg{width:15px;height:15px}
  .message-reaction-pill{min-height:27px;padding:2px 7px;font-size:18px}
  .message-reaction-pill small{font-size:11px}
  .reaction-picker{gap:4px;padding:8px}
  .reaction-picker button{width:43px;height:43px;font-size:25px}
  .reply-quote{font-size:calc(13.5px * var(--font-scale))}
  .chip{font-size:14px;padding:6px 9px;gap:6px}
  .chip svg{width:14px;height:14px}
  .attachment-file-info strong{font-size:15px}
  .attachment-file-info span{font-size:13px}
  .reminder-banner{font-size:15px}
  .pill{font-size:15px;padding:9px 13px}
  .pill svg{width:15px;height:15px}
  .info-card .meta{font-size:14px}
  .info-card button,.secondary,.quiet-danger{font-size:15px;padding:9px 11px}
  .project-card strong{font-size:16px}
  .project-card span{font-size:14px}
  .file-copy span{font-size:13px}
  .file-chat-btn{font-size:14px;padding:9px 11px}
  .save-state{font-size:14px}
  .note-item{padding:7px 10px 7px 5px;grid-template-columns:44px minmax(0,1fr) 34px}
  .note-drag{width:44px;height:46px}
  .note-item-copy strong{font-size:16px}
  .note-item-copy span{font-size:14px}
  .note-drag svg{width:17px;height:17px}
  .note-star{min-width:34px;min-height:44px}
  .note-star svg{width:19px;height:19px}
  .info-card .task-drag{width:44px;height:46px;flex-basis:44px;margin:-6px -4px -6px -6px}
  .info-card .task-drag svg{width:17px;height:17px}
  .note-formatbar{gap:6px;padding:9px 0;overflow-x:auto;flex-wrap:nowrap;scrollbar-width:none}
  .note-formatbar::-webkit-scrollbar{display:none}
  .note-formatgroup{flex:0 0 auto}
  .note-format-divider{flex:0 0 1px;height:28px}
  .note-formatbar button{width:42px;height:40px;font-size:17px;flex:0 0 42px}
  .note-formatbar button.format-text-button{font-size:13px}
  .note-formatbar button svg{width:19px;height:19px}
  .note-body ul,.note-body ol,.note-body ul.checklist{padding-left:3.35em}
  .note-body .list-drag-handle,.note-body ul.checklist>li>.list-drag-handle{left:-3.25em;width:2.05em;height:2.05em;top:-.08em;opacity:.62}
  .note-body .list-drag-handle svg{width:18px;height:18px}
  .note-body ul.checklist>li{padding-left:0}
  .note-body .check-toggle{left:-1.55em;width:1.28em;height:1.28em;top:.07em}
  .search-result span{font-size:14px}
  .sheet label,.login-card label{font-size:15px}
  .sheet-head p{font-size:14px}
  .action-grid strong{font-size:16px}
  .action-grid span{font-size:13px}
  .project-picker-copy strong,.project-new-btn strong{font-size:15px}
  .project-picker-copy small,.project-new-btn small{font-size:13px}
  .check-row strong{font-size:15px}
  .check-row small{font-size:13px}
  .optimize-estimate{font-size:13px}
  .empty-state{font-size:15px}
  .toast{font-size:14px}
  .font-menu{width:184px;max-height:min(70dvh,460px);overflow:auto}
  .font-menu button{font-size:17px;padding:12px}
  .guide-card h3{font-size:17px}
  .guide-card strong{font-size:15px}
  .guide-card p{font-size:14px}
  .guide-card small{font-size:13px}
  .guide-combine strong{font-size:15px}
  .guide-combine p{font-size:14px}
}

@media(max-width:760px){
  .reaction-picker{
    display:grid;
    grid-template-columns:repeat(4,43px);
    gap:4px;
  }

  .app-shell{display:block;max-width:none}
  .sidebar{position:fixed;left:0;top:0;bottom:0;width:250px;transform:translateX(-105%);transition:.18s;box-shadow:12px 0 30px rgba(0,0,0,.12)}
  .sidebar.open{transform:translateX(0)}
  .sidebar-backdrop{display:block;position:fixed;inset:0;background:rgba(30,25,20,.25);z-index:19;opacity:0;pointer-events:none;transition:.18s}
  .sidebar-backdrop.show{opacity:1;pointer-events:auto}
  .mobile-only{display:grid}
  .main{height:100dvh}
  .topbar{height:66px;flex-basis:66px;padding:0 13px}
  .chat-view,.generic-view{padding-left:13px;padding-right:13px}
  .chat-view{padding-bottom:128px}
  .message{max-width:88%}
  .composer{padding-left:11px;padding-right:11px}
  .scratch-layout{grid-template-columns:1fr}
  .note-list{max-height:220px;overflow:auto}
  .action-grid{grid-template-columns:1fr}
  #actionsModal.contextual .action-grid{grid-template-columns:1fr 1fr}
  .two-col{grid-template-columns:1fr}
  .file-card{grid-template-columns:72px minmax(0,1fr)}
  .file-preview-trigger{width:72px;height:58px;grid-row:1 / span 2}
  .file-thumb{width:72px;height:58px}
  .file-chat-btn{grid-column:2;justify-self:start}
  .file-preview-pdf{min-height:420px}
}


@media(max-width:350px){
  #actionsModal.contextual{
    display:flex;
    align-items:flex-end;
    justify-content:center;
    background:rgba(30,25,20,.28);
  }
  #actionsModal.contextual .sheet{
    position:static;
    width:100%;
    max-height:88dvh;
    border-radius:22px 22px 0 0;
    border-left:0;border-right:0;border-bottom:0;
    padding:18px 18px calc(24px + env(safe-area-inset-bottom));
  }
  #actionsModal.contextual .action-grid{grid-template-columns:1fr}
}


@media (prefers-color-scheme: dark){
  :root{
    --paper:#17191b;
    --panel:#202326;
    --sidebar:#1d2022;
    --ink:#f3f0eb;
    --muted:#b9b1aa;
    --line:#3b3e40;
    --accent:#d77760;
    --accent-soft:#3a312d;
    --mine:#493f3a;
    --green:#83a68a;

    --task-bg:#202b24;
    --task-line:#526957;
    --task-ink:#b9d1bd;

    --decision-bg:#282532;
    --decision-line:#625b78;
    --decision-ink:#c9c1dc;

    --project-bg:#2d2920;
    --project-line:#6e6046;
    --project-ink:#d8c394;

    --pin-bg:#30251f;
    --pin-line:#725549;
    --pin-ink:#dbb7a8;

    --reminder-bg:#20292e;
    --reminder-line:#526872;
    --reminder-ink:#b8d0dc;

    --shadow:0 10px 34px rgba(0,0,0,.34);
  }

  html{color-scheme:dark}
  body{background:#101214}
  .login-screen,.auth-loading-screen,.app-shell,.main{background:var(--paper)}
  .login-card,.font-menu,.message,.compose-box,.reply-bar,.info-card,.file-card,
  .note-item,.note-editor,.search-input,.sheet,.project-picker-item.remove-project,
  .project-new-btn,.project-picker-check{
    background:var(--panel);
    color:var(--ink);
  }
  .sidebar{background:var(--sidebar)}
  .topbar{background:rgba(29,32,34,.92)}
  .nav button{color:#c7c0ba}
  .nav button.active{background:#282b2d;color:var(--ink)}
  .nav .count{background:#49362d;color:#eadfd8}
  .icon-control,.text-control,.sheet-close,.info-card button,.secondary,.file-chat-btn{
    background:#292c2f;
  }
  .font-menu button.active,.note-item.active,.note-formatbar button:hover,.note-formatbar button.active{
    background:#303336;
  }
  .note-body .list-drag-handle:hover,.note-body .list-drag-handle:focus,.note-body .list-drag-handle:focus-visible,.note-body .list-drag-handle:active{background:transparent}
  .note-body li.list-item-dragging>.list-drag-handle{background:#303336}
  .note-body .check-toggle{border-color:#8f9498}
  .pill{
    background:#25282a;
    border-color:#45494c;
    color:#d8d1cb;
  }
  .pill.active{
    background:#3a312d;
    border-color:#725549;
    color:#f3ebe6;
  }
  .mine .message{background:var(--mine);border-color:#6f625b}
  .message{border-color:var(--line)}
  .message-meta,.day-divider{color:#aaa39d}
  .message-reaction-pill{
    background:#3d302c;
    border-color:#9d7468;
    color:var(--ink);
    box-shadow:0 1px 5px rgba(0,0,0,.28);
    filter:none;
  }
  .message-reaction-pill small{color:#d2aaa0}
  .message-reaction-pill.mine{
    background:#44332e;
    border-color:#ad796b;
    box-shadow:0 1px 5px rgba(0,0,0,.28);
  }
  .reaction-picker{
    background:#25282a;
    border-color:#45494c;
    box-shadow:0 14px 36px rgba(0,0,0,.42);
  }
  .reaction-picker button:hover,.reaction-picker button.active{background:#35393c}
  .reply-quote{border-color:#72503f;color:#c5bbb4}
  .chip{background:#2c2927;border-color:#5a4b42;color:#d7cec7}
  .attachment-block{background:#1d2022;border-color:var(--line)}
  .attachment-image{background:#111315}
  .attachment-preview{background:#1d2022}
  .file-thumb{background:#292c2f}
  .file-thumb-pdf,.file-preview-pdf{background:#fff}
  .file-preview-content{background:#151719}
  .project-card{
    background:linear-gradient(135deg,var(--panel) 72%,var(--project-bg));
  }
  .note-body mark{background:#8a711b;color:#fff9dc}
  .quiet-danger{background:transparent;color:#df9180}
  .modal{background:rgba(0,0,0,.5)}
  #actionsModal.contextual{background:transparent}
  .action-grid button{background:#25282a}
  .project-picker-icon{background:rgba(255,255,255,.055)}
  .project-picker-item.selected{background:#332e24;box-shadow:0 0 0 2px rgba(216,195,148,.12)}
  .check-row{background:#202326}
  .primary,.send-btn{background:var(--accent);color:white}
  .toast{background:#ece7e1;color:#282522}
  .composer{background:linear-gradient(transparent,var(--paper) 18%)}
  .login-card label,.sheet label{color:#d6cec8}
  .login-card input,.sheet input,.sheet select{
    background:#292c2f;border-color:#4a4f52;color:var(--ink);color-scheme:dark;
  }
  .sheet select option{background:#292c2f;color:var(--ink)}
  .login-card input:focus,.sheet input:focus,.sheet select:focus{
    border-color:#777d81;box-shadow:0 0 0 2px rgba(215,119,96,.13);
  }
  input,textarea,select{color:var(--ink)}
  input::placeholder,textarea::placeholder{color:#96908b}
  .guide-card{background:var(--panel)}
  .guide-label .guide-icon{background:#292c2f;color:#cfc6bf}
  .guide-star .guide-icon{background:#302b23;color:#dec58d}
  .guide-combine{background:#1d2022}
}


/* V1.26 Scratchpad recovery */
#openNoteTrashBtn.has-items{font-weight:600}
.recovery-list{display:flex;flex-direction:column;gap:8px;max-height:min(58vh,520px);overflow:auto;padding:2px}
.recovery-row{display:flex;align-items:center;justify-content:space-between;gap:12px;border:1px solid var(--line);border-radius:12px;padding:10px 11px;background:var(--panel)}
.recovery-row>div{min-width:0;display:flex;flex-direction:column;gap:3px}
.recovery-row strong{font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.recovery-row small{font-size:11px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.compact-button{padding:7px 9px!important;flex:0 0 auto}
.compact-button svg{width:14px;height:14px}
@media(max-width:700px){.recovery-row{align-items:flex-start}.recovery-row small{white-space:normal}.note-actions{flex-wrap:wrap}}


/* V1.30 small Studio additions */
.message-text a{
  color:inherit;
  text-decoration:underline;
  text-decoration-thickness:1px;
  text-underline-offset:2px;
  overflow-wrap:anywhere;
}
.task-new-btn{margin-left:auto}
@media(max-width:700px){
  .task-new-btn{margin-left:0}
}
