/* Shared desk palette and type for the standalone widget and wide workspace. */
:root {
  --bg:#f5f3eb; --bg2:#fffcf5; --bg3:#efede2; --line:#dad8c9; --fg:#323629; --fg-dim:#666959;
  --accent:#637148; --accent-soft:#e6ead8; --rail:#e9e6d7; --paper:rgba(255,253,247,.94);
  --shadow:none; --radius:10px; --rule:#c8c9b5; --highlight:#4b553b; --accent-ink:white;
}
html[data-accent=blue] {--accent:#41688a;--accent-soft:#e3ebef}
html[data-theme=dark] {
  color-scheme:dark; --bg:#222722; --bg2:#2c312a; --bg3:#363c33; --line:#454b3f; --fg:#eeeede;
  --fg-dim:#b4b9a7; --accent:#c3cca1; --accent-soft:#3e4936; --rail:#282e26; --paper:rgba(43,49,41,.96);
  --rule:#59604f; --highlight:#d7ddbd; --accent-ink:#242c1c;
}
html[data-theme=dark][data-accent=blue] {--accent:#a6c5d6;--accent-soft:#34454d}
:root {accent-color:var(--accent)}
body {font-family:"Malgun Gothic",system-ui,sans-serif}
#app,body.character-embedded #app {position:relative;isolation:isolate;max-width:none;width:100%;border:0;background:var(--bg)}
#app.custom-wallpaper::before {content:"";position:absolute;inset:0;background:var(--user-wallpaper) center/cover;opacity:.26;z-index:-1;pointer-events:none}
.icon-defs {position:absolute;pointer-events:none}
.line-icon {width:19px;height:19px;display:inline-block;vertical-align:middle;stroke:currentColor;fill:none;stroke-width:1.65;stroke-linecap:round;stroke-linejoin:round;flex:none;pointer-events:none}
#topbar {border-bottom:1px solid var(--line);padding:9px 20px;gap:12px;min-height:43px;background:var(--paper)}
.desk-top-name {font-size:.86rem;font-weight:700;letter-spacing:-.04em}
.clock-wrap {display:flex;flex-direction:row;align-items:center;gap:7px;line-height:1.2}
#clock {font-size:.85rem;font-weight:600}
#today-label {font-size:.74rem;color:var(--fg-dim);margin:0}
.top-actions {gap:4px}
.top-actions button,.top-actions .ic {border:0;background:transparent;box-shadow:none;color:var(--fg-dim)}
.top-actions button:hover {background:var(--bg3);color:var(--fg)}
#btn-auth {border:1px solid var(--line);background:var(--bg2);color:var(--fg);box-shadow:none}
#btn-auth:hover {background:var(--bg3);color:var(--fg)}
#app button:focus-visible,#app :is(input,select,textarea,summary,a):focus-visible {outline:2px solid var(--accent);outline-offset:2px}
#app input:not([type=checkbox]):not([type=range]),#app select,#app textarea {font-family:inherit;border:1px solid var(--line);border-radius:6px;background:var(--bg2);color:var(--fg);min-width:0}
#app input::placeholder,#app textarea::placeholder {color:var(--fg-dim);opacity:.9}
#app button:disabled {opacity:.53;cursor:default}
#app main {scrollbar-color:var(--rule) transparent}
main:not(#view-study) {padding:18px clamp(14px,3vw,36px);margin:0 auto;width:100%;max-width:1200px}
#statusbar {background:var(--bg);color:var(--fg-dim);border-top:1px solid var(--line);padding-inline:18px}
#tabs {background:var(--rail);color:var(--fg)}
#tabs button {font:inherit;color:var(--fg);border:0;background:transparent;box-shadow:none}
#tabs .tab.active {background:var(--paper);color:var(--highlight);box-shadow:0 1px 3px #26291415}
#tabs .tab:hover,#tabs .desk-shortcuts button:hover {background:var(--bg2)}
.desk-pages {display:flex}
.desk-brand {font-size:1.08rem;font-weight:760;letter-spacing:-.07em;align-items:center;gap:9px}
.desk-brand svg {width:30px;height:30px;color:var(--highlight)}
#view-study {padding:20px clamp(14px,2.3vw,28px) 22px;width:100%;max-width:1240px;margin:0 auto}
.desk-title {display:flex;align-items:center;justify-content:space-between;gap:8px;margin:0 0 16px}
.desk-title h1 {font-size:clamp(1.4rem,2.5vw,1.95rem);letter-spacing:-.075em;line-height:1.18}
.desk-dates {display:flex;align-items:center;gap:5px}
#view-study .desk-dates input {width:auto;padding:4px 7px;font-size:.76rem}
#view-study .desk-dates button {font-size:.75rem;padding:5px 8px;background:var(--paper)}
.desk-columns {display:grid;grid-template-columns:minmax(0,1.22fr) minmax(0,.89fr);gap:14px;align-items:start}
.desk-primary,.desk-secondary,.desk-tools {min-width:0;display:grid;gap:12px}
.study-hero,.study-card,#rail-companion .study-card {border-radius:10px;border:1px solid var(--line);background:var(--paper);margin:0;box-shadow:0 2px 5px #34321e06;min-width:0}
.study-card {padding:15px}
#view-study h3 {font-weight:720;font-size:1.03rem;letter-spacing:-.055em;margin:0 0 9px}
#view-study .study-card label {font-size:.8rem;color:var(--fg-dim);gap:4px}
#view-study .study-card input,#view-study .study-card select,#view-study .study-card textarea {font-size:.86rem}
#view-study button,#study-open-day {background:var(--bg3);border-radius:6px;border:1px solid var(--line);font-size:.82rem;padding:5px 9px;color:var(--fg)}
#view-study button:hover,#study-open-day:hover {border-color:var(--accent)}
#view-study button[type=submit],#view-study #study-stop {background:var(--accent);color:var(--accent-ink);border-color:transparent}
#view-study .study-hero {position:relative;overflow:hidden;isolation:isolate;padding:18px 20px 0;background-color:#ece5cc;color:#383d2a;border-color:#cbcab7}
.study-hero::before {content:"";position:absolute;inset:0;z-index:-1;background-image:linear-gradient(90deg,#f6edd9 0%,#f6edd9ee 18%,#f6edd974 51%,transparent 75%),var(--user-wallpaper,url("desk-art.jpg"));background-position:center,center 59%;background-size:cover}
html[data-theme=dark] #view-study .study-hero {background:#31392b;color:#f3f0d8;border-color:#5c644f}
html[data-theme=dark] .study-hero::before {background-image:linear-gradient(90deg,#30382c 2%,#30382cf0 25%,#30382c9c 61%,#222b1f65),var(--user-wallpaper,url("desk-art.jpg"))}
#view-study .timer-face h2 {font-size:.83rem;font-weight:650;letter-spacing:.015em}
#study-clock {display:block;font-size:clamp(2.6rem,5vw,4.2rem);font-family:Georgia,"Times New Roman",serif;font-weight:400;font-variant-numeric:lining-nums tabular-nums;letter-spacing:-.065em;line-height:1.22;margin:4px 0 18px}
#study-timer {display:flex;gap:5px;align-items:center;margin:0 0 15px;max-width:265px}
#view-study #study-timer input {font-size:.84rem;min-width:0;flex:1;background:var(--bg2);padding:6px 9px}
#view-study #study-timer button {background:var(--highlight);color:var(--bg2);font-size:.82rem;border:0;padding:7px 12px}
.desk-totals {margin:0 -20px;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));background:#f6f1e1eb;color:#393e2c;border-top:1px solid #c8c8af}
.desk-totals div {display:grid;gap:2px;padding:9px 12px;border-right:1px solid #d9d7c4}
.desk-totals div:last-child {border:0}
.desk-totals span {font-size:.67rem;color:#525840}
#view-study .desk-totals strong {font-size:1.07rem;line-height:1.25;font-variant-numeric:tabular-nums}
html[data-theme=dark] .desk-totals {background:#30372cec;color:#e0e5d3;border-color:#58604d}
html[data-theme=dark] .desk-totals div {border-color:#505744}
html[data-theme=dark] .desk-totals span {color:#c0c7b1}
.subject-list {list-style:none;margin:3px 0 8px;max-height:240px;overflow:auto}
.subject-list li {padding:8px 10px;margin:4px 0;background:var(--bg3);border-radius:6px;display:flex;align-items:center;gap:8px;font-size:.86rem;overflow-wrap:anywhere}
.subject-list li:has(button)::before {content:"";width:8px;height:8px;border-radius:2px;flex:none;background:#92a77c}
.subject-list li:nth-child(3n+2)::before {background:#cfab73}
.subject-list li:nth-child(3n)::before {background:#ad9ba9}
.subject-list li span {flex:1}
.subject-list small {color:var(--fg-dim)}
#view-study .subject-list button {padding:2px 8px;background:var(--bg2)}
.subject-card details {margin-top:6px;border-top:1px solid var(--line);padding-top:6px}
#view-study details>summary {font-size:.8rem;color:var(--fg-dim);cursor:pointer}
#study-week {margin:4px 0 8px;gap:4px}
#study-week div {font-size:.66rem;color:var(--fg-dim)}
#study-week i {background:var(--accent);opacity:.80;min-width:8px;max-width:24px}
#study-week-total {font-size:.73rem;color:var(--fg-dim)}
#study-carry {float:right;margin-top:-31px}
#view-study #study-carry {font-size:.68rem;background:transparent;padding:3px 5px}
#view-study #study-task {clear:both}
#study-task-input {flex:1}
.study-list li {min-width:0;font-size:.82rem}
.studio .ambient-controls {margin-top:9px;padding-top:9px}
#view-study #room-volume {accent-color:var(--accent)}
#study-feedback {position:static;margin:8px 0 0;font-size:.82rem}
.desk-tools {grid-template-columns:repeat(2,minmax(0,1fr));align-items:start;margin-top:14px}
.desk-tools .study-card {padding:11px 14px}
#companion-home:empty {display:none}
#study-player {min-width:0}
#view-study .study-actions {flex-wrap:wrap}
#month-cal {background:var(--paper);border-radius:9px}
#month-cal .n {line-height:1.55}
#month-cal .study-pill {color:var(--highlight);font-size:.67rem;line-height:1.3;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#month-cal .mcal-cell {padding:4px;min-width:0}
#month-cal .mcal-cell.today .n {background:var(--highlight);color:var(--bg2)}
#tabs #rail-companion .room-scene {display:grid;grid-template-columns:40px minmax(0,1fr);gap:5px}
#rail-companion .study-card {padding:10px;background:var(--paper)}
#tabs #room-greet {border-radius:7px;background:var(--bg3);width:36px;height:40px}
#rail-companion #room-character {font-size:1.6rem}
#rail-companion h3 {font-size:.8rem;line-height:1.2}
#rail-companion #room-state,#rail-companion #room-mini,#rail-companion #room-speech {font-size:.72rem}
#rail-companion select {grid-column:1/-1;width:100%;padding:3px;font-size:.76rem}
#rail-companion #room-mini {display:block;margin-top:6px;color:var(--fg-dim)}
@media(min-width:760px) {
  #app,body.character-embedded #app {padding-left:clamp(144px,16vw,190px)}
  #tabs {position:absolute;left:0;top:0;bottom:0;display:flex;flex-direction:column;align-items:stretch;width:clamp(144px,16vw,190px);padding:22px 12px 14px;border:0;border-right:1px solid var(--line);overflow:auto}
  .desk-brand {display:flex;margin:0 2px 24px;white-space:nowrap}
  .desk-pages,.desk-shortcuts {display:flex;flex-direction:column;gap:3px}
  #tabs .tab,#tabs .desk-shortcuts button {flex:none;display:flex;flex-direction:row;align-items:center;justify-content:flex-start;gap:9px;padding:9px 12px;font-size:.88rem;text-align:left;border-radius:6px}
  .desk-shortcuts {border-top:1px solid var(--rule);padding-top:12px;margin-top:14px}
  #rail-companion {margin-top:auto;padding-top:24px}
  .top-actions .compact-player {display:none}
  #month-cal .mcal-cell {min-height:clamp(59px,8.9vh,96px);font-size:.9rem}
}
@media(max-width:759px) {
  #view-study {padding:12px 13px 16px}
  .desk-columns,.desk-tools {grid-template-columns:minmax(0,1fr)}
  .desk-brand,.desk-shortcuts,#rail-companion,.desk-top-name {display:none}
  #tabs {padding:3px 5px calc(3px + env(safe-area-inset-bottom,0px));border-top:1px solid var(--line)}
  .desk-pages {width:100%;gap:3px}
  #tabs .tab {min-width:0;padding:5px 1px;gap:2px;border-radius:7px}
  #tabs .tab .lbl {font-size:.68rem}
  #topbar {padding:6px 9px;gap:4px}
  .clock-wrap {flex-direction:column;align-items:flex-start;gap:1px}
  .top-actions {gap:1px}
  .top-actions .ic {width:27px;height:27px}
  .desk-title {margin-bottom:10px}
  .desk-title h1 {font-size:1.4rem}
  #view-study .desk-dates input {width:111px}
  #view-study .study-hero {padding:12px 14px 0}
  #study-clock {margin:2px 0 12px;font-size:2.9rem}
  #study-timer {max-width:220px;margin-bottom:12px}
  .desk-totals {margin:0 -14px}
  .study-card {padding:12px}
  #month-cal .mcal-cell {padding:3px 1px}
  #month-cal .study-pill {font-size:.59rem;letter-spacing:-.06em}
  #statusbar {font-size:.68rem}
}
@media(max-width:360px){#topbar .top-actions .ic {width:23px}#btn-auth{padding-inline:7px}.desk-title {flex-wrap:wrap}}

/* The night scene, desk ledger and month index share a single reading surface. */
:root {
  --bg:#f3f1f3;--bg2:#fbf9fa;--bg3:#e8e4ec;--line:#cec8d5;--fg:#302c40;--fg-dim:#635d71;--rule:#bab1c5;
  --paper:#f8f6f8;--rail:#222337;--highlight:#514b60;--radius:0;
  --scene-ink:#f7e9cf;--scene-muted:#cfc9dc;--night-rule:#6c6079;--night-gold:#f4c88c;
}
html[data-theme=dark] {
  --bg:#202130;--bg2:#292a3b;--bg3:#343446;--line:#494658;--fg:#f0eaf1;--fg-dim:#b6afc1;--rule:#5c556d;
  --paper:#272837;--rail:#191b2a;--highlight:#e3cfab;
}
#tabs {background:var(--rail);color:#f1e6d9}
#tabs button,#tabs .desk-brand svg {color:#d4cada}
#tabs .desk-brand {color:#f2d6aa}
#tabs .tab.active {color:#fee2ac;background:#39374c;box-shadow:inset 3px 0 #edbc79}
#tabs .tab:hover,#tabs .desk-shortcuts button:hover {background:#343447;color:#fff1d9}
#tabs .desk-shortcuts {border-color:#4d485e}
#tabs .tab,#tabs .desk-shortcuts button {border-radius:0}
#topbar {background:var(--bg);border-bottom:1px solid var(--line)}
#view-study {padding-top:15px}
.desk-title {margin-bottom:11px}
.desk-title h1 {font-size:clamp(1.45rem,2.4vw,1.85rem)}
#app input:not([type=checkbox]):not([type=range]),#app textarea,#app select,#view-study button,#study-open-day,#btn-auth,#ev-month-nav button {border-radius:0}
#view-study #night-room {position:relative;isolation:isolate;display:grid;grid-template-columns:minmax(0,27%) 1fr minmax(0,28%);align-items:start;min-height:clamp(251px,26vw,335px);padding:18px 17px 14px;margin:0;background:#202034;color:var(--scene-ink);border:1px solid #454354;border-radius:0;box-shadow:none;overflow:hidden}
#view-study #night-room::before {display:none}
.scene-landscape {position:absolute;inset:0;z-index:-1;background:var(--user-wallpaper,url("desk-art.jpg")) center 67% /cover no-repeat;image-rendering:pixelated}
.scene-landscape::before {content:"";position:absolute;inset:0;background:linear-gradient(90deg,#100f21d9 0%,#1313239e 16%,transparent 39%,transparent 60%,#151225a1 82%,#151325d9 100%);pointer-events:none}
.scene-tasks,.scene-timer {min-width:0;display:flex;flex-direction:column;align-self:start;text-shadow:0 1px 2px #110f20}
.scene-timer {grid-column:3;text-align:right;align-items:stretch}
#view-study .scene-timer h2,#view-study .scene-tasks h3 {font-size:.83rem;font-weight:700;line-height:1.4;margin:0 0 5px;letter-spacing:.01em;color:#ffe3ad}
#study-clock {font:600 clamp(1.75rem,3.55vw,3.65rem)/1.12 Consolas,ui-monospace,monospace;letter-spacing:-.075em;font-variant-numeric:tabular-nums;margin:0 0 8px;white-space:nowrap}
#view-study #night-room input:not([type=checkbox]) {color:#fcf2df;background:#1b1a2ddb;border:0;border-bottom:1px solid #928298;font-size:.77rem;box-shadow:none;padding:5px 4px;height:28px}
#view-study #night-room input::placeholder {color:#d8ccdc}
#night-room #study-timer {max-width:none;width:100%;margin:0;gap:4px}
#view-study #night-room button:not(#scene-pet) {border-radius:0;font-size:.72rem;padding:3px 6px;line-height:1.2}
#view-study #night-room button[type=submit],#view-study #night-room #study-stop {color:#282032;background:#f1c58c;font-weight:700;border:0;min-height:28px}
#view-study #night-room #study-task button {background:#353043;color:#ffe0ac;border:1px solid #796777}
.scene-tasks #study-task {order:2;gap:4px;display:flex;margin:0}
.scene-tasks #study-tasks {order:1;max-height:94px;overflow:auto;scrollbar-width:thin;margin:0 0 7px;scrollbar-color:#aaa0b2 #282538}
.scene-tasks #study-tasks:empty {display:none}
#night-room #study-tasks li {background:#17172787;border:0;border-bottom:1px solid #82738970;padding:4px 2px;gap:5px;line-height:1.25;font-size:.78rem}
#night-room #study-tasks input[type=checkbox] {width:14px;height:14px;accent-color:#e3bb89}
#night-room #study-tasks button {color:#d9cad7;background:transparent;border:0;font-size:.65rem;padding:4px}
#night-room #study-tasks .done {color:#c0b5bc}
#view-study #night-room #study-carry {order:3;align-self:flex-start;float:none;text-align:left;margin:6px 0 0;padding:3px 0;color:#ddc9b9;border:0;background:transparent;text-decoration:underline;text-underline-offset:3px;font-size:.65rem}
.scene-pet-anchor {position:absolute;left:68%;top:77%;transform:translate(-50%,-100%);width:clamp(49px,5.4vw,82px);aspect-ratio:48/36}
#night-room[data-mode=working] .scene-pet-anchor {left:51%;top:81%}
#view-study #scene-pet {display:block;padding:0;border:0;background:none;width:100%;height:100%;box-shadow:none;touch-action:manipulation}
#scene-pet span {display:block;width:100%;height:100%;image-rendering:pixelated;background-image:url("desk-pals.png");background-size:300% 200%;background-position:var(--pet-x,0%) var(--pet-y,0%);filter:drop-shadow(1px 2px 0 #1a132861)}
[data-pal=cat] {--pet-x:50%}
[data-pal=fox] {--pet-x:100%}
[data-mode=working] {--pet-y:100%}
@media(prefers-reduced-motion:no-preference){#night-room[data-mode=working] #scene-pet span{animation:desk-nod 1.8s steps(1,end) infinite}@keyframes desk-nod{55%{transform:translateY(-2px)}}}
#scene-speech {pointer-events:none;position:absolute;bottom:95%;left:50%;transform:translateX(-60%);width:max-content;max-width:138px;padding:5px 8px;background:#262337;color:#f5ebd8;border:1px solid #b7a6ad;font-size:.73rem}
#scene-speech:empty {display:none}
#view-study .desk-totals {margin:0 0 15px;background:var(--bg3);color:var(--fg);border:0;border-bottom:1px solid var(--rule)}
#view-study .desk-totals div {display:flex;align-items:baseline;gap:9px;padding:8px 12px;border-color:var(--line)}
#view-study .desk-totals span {color:var(--fg-dim)}
#view-study .desk-totals strong {font-size:.94rem}
.desk-columns {gap:24px;grid-template-columns:minmax(0,1.16fr) minmax(0,1fr)}
.desk-primary,.desk-secondary {gap:14px}
#view-study .study-card:not(.studio),#rail-companion .study-card {margin:0;padding:10px 0 7px;background:transparent;box-shadow:none;border:0;border-top:1px solid var(--rule);border-radius:0}
#view-study .studio {border:0;border-top:1px solid var(--rule);border-radius:0;box-shadow:none;background:transparent;padding:10px 0}
.subject-list {gap:0}
.subject-list li {background:transparent;border-radius:0;border-bottom:1px solid var(--line);padding:6px 0}
.subject-list li::before {border-radius:0}
#rail-companion .study-card {color:#eee1da;border-color:#514b62}
#rail-companion #room-state,#rail-companion #room-mini,#rail-companion #room-speech {color:#d0c5d2}
#tabs #room-greet {background:#363347;border-radius:0}
#study-week i {border-radius:0}
.month-sheet:has(#month-cal[hidden]) {display:none}
.month-sheet {display:grid;grid-template-columns:minmax(0,1fr) 36px;align-items:stretch;margin:0 0 14px;background:#212035;color:#e8e1ec}
#month-cal {margin:0;border:0;border-top:1px solid #68647b;border-left:1px solid #534e68;border-radius:0;box-shadow:none;background:#26253b;grid-template-columns:repeat(7,minmax(0,1fr))}
#month-cal .cal-head {background:#302e46;color:#e6ddeb;font:600 .78rem/1.6 Consolas,system-ui,sans-serif;padding:5px 0}
#month-cal .cal-head.sun,#month-cal .sun .n,#month-cal .hname {color:#f3a6af}
#month-cal .mcal-cell {border:0;border-top:1px solid #534e68;border-right:1px solid #534e68;padding:5px 6px}
#month-cal .mcal-cell .n {text-align:left;align-self:start;color:#eae3ed;font-family:Consolas,monospace}
#month-cal .mcal-cell.sun .n {color:#f3a6af}
#month-cal .mcal-cell.out {opacity:1;color:#908ba3}
#month-cal .mcal-cell.out .n {color:#908ba3}
#month-cal .mcal-cell.today .n {background:#eac18c;color:#2b2334;border-radius:0;margin:0;padding:0 3px;width:auto}
#month-cal .mcal-cell.sel,#month-cal .mcal-cell:not(.out):hover {background:#403c56}
#month-cal .mcal-cell.sel {box-shadow:inset 0 0 0 1px #c6acce}
#month-cal .study-pill {color:#b5d9cb}
.month-index {display:grid;grid-template-columns:1fr;background:#212035}
.month-index button {min-width:0;min-height:23px;padding:1px;border:0;border-bottom:1px solid #514b66;border-left:1px solid #615777;background:#353248;color:#dbd1e1;font:600 .76rem/1.25 Consolas,monospace}
.month-index button:hover,.month-index button:focus-visible {background:#4b445d}
.month-index button[aria-pressed=true] {color:#30243a;background:#efc68e}
#view-events #range-toggle .rbtn,#view-events .pill {border-radius:0}
@media(max-width:899px){
  #view-study #night-room {padding:0;grid-template-columns:1fr 1fr;align-items:start;min-height:0;gap:0;background:#252436}
  .scene-landscape {position:relative;inset:auto;grid-column:1/-1;aspect-ratio:3.25;min-height:121px;z-index:0}
  .scene-landscape::before {background:none}
  .scene-tasks,.scene-timer {padding:10px 12px;background:#252436;align-self:stretch}
  .scene-tasks {grid-column:1;grid-row:2;border-right:1px solid #51495e}
  .scene-timer {grid-column:2;grid-row:2}
  #study-clock {font-size:clamp(1.55rem,4.9vw,2.65rem)}
  #night-room .scene-pet-anchor {width:clamp(37px,8vw,59px)}
}
@media(max-width:759px){
  #view-study {padding:10px 10px 14px}
  .desk-columns {grid-template-columns:minmax(0,1fr);gap:12px}
  #view-study .desk-totals div {display:grid;gap:1px;padding:5px 9px}
  #tabs .tab.active {box-shadow:inset 0 2px #edbc79}
  .month-sheet {grid-template-columns:minmax(0,1fr)}
  .month-index {grid-template-columns:repeat(6,minmax(0,1fr));order:-1}
  .month-index button {min-height:25px}
  #month-cal .mcal-cell {min-height:42px;padding:3px 2px}
}
@media(max-width:449px){
  #view-study #night-room {grid-template-columns:minmax(0,1fr)}
  .scene-timer {grid-column:1;grid-row:2;display:grid;grid-template-columns:auto 1fr;align-items:center;gap:9px;text-align:left;padding:9px 10px;border-top:1px solid #51495e}
  #view-study .scene-timer h2 {font-size:.63rem;margin:0}
  #study-clock {font-size:1.48rem;margin:0}
  .scene-tasks {grid-column:1;grid-row:3;border:0;border-top:1px solid #51495e;padding:8px 10px}
  #view-study .scene-tasks h3 {margin-bottom:4px}
  #view-study #night-room #study-carry {margin-top:3px}
}

/* Pastel desktop colors and contrast for text over the room artwork. */
:root {--bg:#f6effb;--bg2:#fffaff;--bg3:#e8dcfa;--line:#c8b7df;--fg:#342954;--fg-dim:#66567f;--rule:#b5a0d1;--paper:#fcf6ff;--rail:#e3d5f6;--highlight:#514077;--accent:#70539b;--accent-soft:#e9daf8;--accent-ink:#fffaff;--scene-ink:#392956;--scene-muted:#645780}
html[data-accent=olive] {--accent:#626948;--accent-soft:#e4e7d4}
html[data-accent=blue] {--accent:#526ca4;--accent-soft:#e0e7f8}
html[data-accent=sage] {--accent:#41715d;--accent-soft:#d9ece5}
html[data-accent=plum] {--accent:#88538a;--accent-soft:#eed9ed}
html[data-accent=amber] {--accent:#88612c;--accent-soft:#f5e6c5}
html[data-theme=dark] {--bg:#29243c;--bg2:#332d49;--bg3:#423752;--line:#665577;--fg:#f5eafa;--fg-dim:#d0bddb;--rule:#746285;--rail:#322a47;--paper:#322c43;--highlight:#ead5fa;--accent-ink:#2a203b}
html[data-theme=dark][data-accent=iris] {--accent:#d0b5ff;--accent-soft:#55446a}
html[data-theme=dark][data-accent=olive] {--accent:#c3cca1}
#topbar {background:var(--bg2)}
.desk-title h1 {color:var(--fg)}
#tabs {color:#3e305c;background:linear-gradient(155deg,#dccbf6 10%,#e9d7f6 62%,#d7dffa 100%);border-color:#b3a0cc}
#tabs button,#tabs .desk-brand svg,#tabs .desk-brand {color:#493663}
#tabs .tab.active {background:#fff3fc;color:#463165;box-shadow:inset 3px 0 #9965ab}
#tabs .tab:hover,#tabs .desk-shortcuts button:hover {background:#f2e6fb;color:#463165}
#tabs .desk-shortcuts,#tabs #rail-companion .study-card {border-color:#b9a5ce}
#tabs #rail-companion .study-card,#rail-companion #room-state,#rail-companion #room-mini,#rail-companion #room-speech {color:#514363}
#tabs #room-greet {background:transparent}
html[data-theme=dark] #tabs {background:linear-gradient(150deg,#413551,#302c47);border-color:#655675}
html[data-theme=dark] #tabs :is(button,.desk-brand,svg,#room-state,#room-mini,#room-speech,h3) {color:#f1def6}
html[data-theme=dark] #tabs .tab.active,html[data-theme=dark] #tabs button:hover {background:#554766}
#view-study #night-room {border-color:#a487c2;background:#d7c2ed;color:#392956}
.scene-landscape::before {background:linear-gradient(90deg,#ffedffeb 0%,#fce9ffe0 14%,#f5e1fa66 26%,transparent 36%,transparent 63%,#f0e2ff73 74%,#eee3ffd9 88%,#f4e8ffec 100%)}
.scene-tasks,.scene-timer {text-shadow:none}
#view-study .scene-timer h2,#view-study .scene-tasks h3 {color:#4d3469}
#view-study #night-room input:not([type=checkbox]) {background:#fff7ffd9;border-bottom-color:#a18ab9;color:#382653}
#view-study #night-room input::placeholder {color:#705c80}
#view-study #night-room button[type=submit],#view-study #night-room #study-stop {color:#fff8ff;background:#694c90}
#view-study #night-room #study-task button {color:#503967;background:#efdcfa;border-color:#a18ab9}
#night-room #study-tasks li {background:#fff3ffc4;border-color:#ad91bea3}
#night-room #study-tasks input[type=checkbox] {accent-color:#81609f}
#night-room #study-tasks .done,#night-room #study-tasks button {color:#715c7e}
#view-study #night-room #study-carry {color:#5d476e}
#night-room .scene-pet-anchor {left:65%;top:84%}
#night-room[data-mode=working] .scene-pet-anchor {left:49%;top:88%}
#scene-speech {background:#fff4ff;color:#483363;border-color:#9c80b6}
html[data-theme=dark] .scene-landscape {filter:brightness(.83) saturate(.88)}
#view-study .desk-totals {background:linear-gradient(90deg,#efd8ec,#e6dcfa 50%,#dce8fb);color:#462f60;border-color:#baa6d0}
#view-study .desk-totals div {border-color:#baa6d0}
#view-study .desk-totals span {color:#655371}
#view-study .desk-columns {border-top:0}
.month-sheet {background:#ece3f7;color:#392e56}
#month-cal {background:#faf5ff;border-color:#baabcf}
#month-cal .cal-head {background:#dddcf9;color:#493869}
#month-cal .cal-head.sun,#month-cal .mcal-cell.sun .n,#month-cal .hname {color:#96436e}
#month-cal .mcal-cell {border-color:#c9b8d9}
#month-cal .mcal-cell .n {color:#42355a}
#month-cal .mcal-cell.out .n {color:#7d748a}
#month-cal .mcal-cell.today .n {background:#f5b6d4;color:#482c55}
#month-cal .mcal-cell.sel,#month-cal .mcal-cell:not(.out):hover {background:#ece0f7}
#month-cal .mcal-cell.sel {box-shadow:inset 0 0 0 2px #9276ac}
#month-cal .study-pill {color:#5c4486}
.month-index {background:#e3daf1}
.month-index button {background:#dfdcf9;color:#554569;border-color:#bbacce}
.month-index button:nth-child(3n+1) {background:#eddbf0}
.month-index button:nth-child(3n) {background:#d9e5f9}
.month-index button:hover,.month-index button:focus-visible {color:#453259;background:#f1cee8}
.month-index button[aria-pressed=true] {color:#482c55;background:#f4b6d5;box-shadow:inset -3px 0 #9564a3}
html[data-theme=dark] #month-cal {background:#353047}
html[data-theme=dark] #month-cal .cal-head {background:#49405d;color:#f7e6fb}
html[data-theme=dark] #month-cal .mcal-cell {border-color:#685a78}
html[data-theme=dark] #month-cal .mcal-cell .n {color:#efe6fb}
html[data-theme=dark] #month-cal .mcal-cell.sun .n {color:#f2b6d1}
html[data-theme=dark] #month-cal .mcal-cell.out .n {color:#aaa0b9}
html[data-theme=dark] #month-cal .mcal-cell.today .n {color:#482c55}
html[data-theme=dark] #month-cal .study-pill {color:#d8c0f0}
html[data-theme=dark] #month-cal .mcal-cell.sel,html[data-theme=dark] #month-cal .mcal-cell:not(.out):hover {background:#564962}
#app:has(#night-room[data-pal=cat]) #room-character {--pet-x:50%}
#app:has(#night-room[data-pal=fox]) #room-character {--pet-x:100%}
#app:has(#night-room[data-mode=working]) #room-character {--pet-y:100%}
#app #room-character {display:block;width:34px;height:26px;font-size:0;background:url("desk-pals.png") var(--pet-x,0%) var(--pet-y,0%) / 300% 200%;image-rendering:pixelated}
@media(max-width:899px){.scene-landscape::before {background:none}.scene-timer,.scene-tasks {background:#eee4f7;border-color:#c4add9}.scene-tasks {border-color:#b8a1cf}}
@media(max-width:759px){#tabs .tab.active {box-shadow:inset 0 2px #9965ab}}

#writing-storage {display:none}
#app:has(#view-writing:not([hidden])) #status {display:none}
#app:has(#view-writing:not([hidden])) #writing-storage {display:inline}
#view-writing:not([hidden]) {display:flex;min-height:0;padding:0;overflow:hidden;align-self:stretch}
#view-writing[hidden],#writing-frame[hidden],#writing-connect[hidden] {display:none}
#writing-frame {width:100%;height:100%;flex:1;min-height:0;border:0;background:var(--bg)}
#writing-connect {align-self:center;max-width:33em;margin:auto;padding:20px;line-height:1.6}
@media(max-width:759px){#tabs .desk-pages .tab{min-width:0}}
.writing-tools {margin:8px 0;padding:8px 0;border-top:1px solid var(--line)}
.writing-tools h4 {margin:0 0 6px;font-size:.85rem}
#labyrinth-actions:not([hidden]) {display:flex;flex-wrap:wrap;align-items:center;gap:6px}
#view-study .writing-tools button {font:inherit;font-size:.8rem;padding:4px 7px}
#labyrinth-status {font-size:.75rem;color:var(--fg-dim);line-height:1.5;margin:5px 0 0;overflow-wrap:anywhere}

#view-writing:not([hidden]) {flex-direction:column}
#view-writing [hidden] {display:none!important}
.writing-toolbar {
  --action-height:36px;
  display:flex;align-items:center;justify-content:space-between;gap:8px;flex:none;
  padding:3px 16px;background:var(--bg2);border-bottom:1px solid var(--line);
}
.writing-views {display:flex;align-items:center;gap:4px;min-width:0}
.writing-toolbar button,#writing-pad button {
  box-sizing:border-box;min-height:var(--action-height,36px);padding:0 12px;
  font:600 13px/1.3 "Malgun Gothic",system-ui,sans-serif;color:var(--fg);
  background:var(--bg2);border:1px solid var(--line);border-radius:2px;
}
.writing-views button {border-color:transparent;background:transparent;color:var(--fg-dim);white-space:nowrap}
.writing-views button[aria-pressed=true] {color:var(--highlight);background:var(--accent-soft);box-shadow:inset 0 -2px var(--accent)}
.writing-toolbar button:hover,#writing-pad button:hover {background:var(--bg3)}
.writing-tools-toggle {anchor-name:--writing-tools;white-space:nowrap}
.writing-tools-toggle span {margin-left:4px}
#writing-tools-menu {
  position:fixed;inset:88px 12px auto auto;margin:0;min-width:152px;padding:4px;
  border:1px solid var(--line);background:var(--bg2);color:var(--fg);box-shadow:0 4px 14px #30203c29;
}
@supports (top:anchor(bottom)) {
  #writing-tools-menu {position-anchor:--writing-tools;inset:auto;top:anchor(bottom);right:anchor(right);margin-top:4px}
}
#writing-tools-menu button {display:block;width:100%;border:0;text-align:left;background:transparent}
#writing-tools-menu button:hover {background:var(--accent-soft)}
#writing-tools-menu #link-toggle {border-top:1px solid var(--line)}
#pad-list [aria-pressed=true] {color:var(--fg);border-color:var(--accent);box-shadow:inset 0 -2px var(--accent)}
#writing-manuscript:not([hidden]) {display:flex;flex:1;min-height:0}
#writing-pad:not([hidden]) {display:grid;grid-template-columns:minmax(140px,24%) minmax(0,1fr);flex:1;min-height:0;background:var(--bg2)}
#writing-pad aside,.pad-editor {display:flex;flex-direction:column;min-width:0;min-height:0;gap:8px;padding:12px}
#writing-pad aside {background:var(--bg);border-right:1px solid var(--line)}
#pad-search,#pad-text {box-sizing:border-box;width:100%;font:inherit;background:var(--bg2);color:var(--fg);border:1px solid var(--line);padding:8px}
#pad-list {display:grid;align-content:start;gap:3px;overflow:auto}
#writing-pad #pad-list button {display:block;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#pad-text {resize:none;min-height:90px;flex:1;line-height:1.7;padding:12px}
.pad-actions {display:flex;flex-wrap:wrap;align-items:center;gap:6px}
#pad-status,#pad-empty {font-size:.77rem;color:var(--fg-dim);margin:0}
#pad-status {margin-inline-end:auto}
#app:has(#writing-pad:not([hidden])) #writing-storage {visibility:hidden}
@media(max-width:640px){
  #writing-pad:not([hidden]) {grid-template-columns:1fr;grid-template-rows:auto minmax(0,1fr);overflow:auto}
  #writing-pad aside {display:grid;grid-template-columns:auto minmax(0,1fr);border:0;border-bottom:1px solid var(--line);gap:5px}
  #pad-list,#pad-empty {grid-column:1/-1} #pad-list {max-height:74px}
  .pad-editor,#writing-pad aside {padding:8px}
}

.scene-links, #writing-link-dialog {overflow-wrap:anywhere}
.writing-link-bar {flex:0 0 auto; margin:0 12px}
.link-actions {display:flex;align-items:center;flex-wrap:wrap;gap:6px}
.scene-links button, #link-form button {font:inherit;cursor:pointer;color:inherit;background:var(--bg2);border:1px solid var(--line,GrayText);border-radius:7px;padding:4px 9px}
#writing-link-status, #link-form-status {font-size:.85em;margin:4px 0}
#writing-link-status:empty, #link-form-status:empty {display:none}
#link-shelf {max-height:min(32vh,280px);overflow:auto;margin:8px 0}
.scene-cards {list-style:none;padding:0;display:grid;gap:8px}
.scene-cards li {display:block;padding:8px 10px;border-inline-start:2px solid var(--accent,currentColor);min-width:0}
.scene-cards p, .scene-cards blockquote, #link-quote {white-space:pre-wrap;margin:4px 0}
.scene-cards blockquote {display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
#writing-link-dialog {box-sizing:border-box;width:min(420px,92vw);max-height:85vh;border:1px solid var(--line,GrayText);border-radius:12px;background:var(--bg2);color:var(--fg);padding:18px}
#writing-link-dialog::backdrop {background:rgb(0 0 0 / .35)}
#link-form {display:grid;gap:10px}
#link-form h2 {margin:0} #link-form label {display:grid;gap:4px}
#link-form textarea {box-sizing:border-box;width:100%;font:inherit}
#link-delivery:not([hidden]) {display:flex;flex-wrap:wrap;align-items:end;gap:8px}
#link-quote {max-height:7em;overflow:auto;border-inline-start:2px solid var(--accent,currentColor);padding-inline-start:8px}

.pad-actions {flex-wrap:wrap}
@media(max-width:600px){
  .writing-toolbar {--action-height:44px;padding:2px 6px;gap:3px}
  .writing-views {gap:0}
  .writing-toolbar button {padding-inline:8px}
}
@media(max-width:360px){
  .writing-toolbar {padding-inline:3px}
  .writing-toolbar button {padding-inline:5px}
  .writing-toolbar .studio-prefix {display:none}
  .writing-tools-toggle span {margin-left:0}
}

/* Shared controls for the scheduler, in the wide workspace and the tray widget. */
#app {--action-height:36px;--page-gutter:clamp(14px,2.8vw,32px)}
#topbar {min-height:48px;padding:4px 14px;gap:12px}
#topbar .top-actions {gap:6px}
#topbar .top-actions > button {
  align-items:center;justify-content:center;gap:6px;min-height:var(--action-height);height:auto;
  padding:0 10px;border:1px solid transparent;border-radius:2px;font-size:13px;font-weight:600;
}
#topbar #btn-search,#topbar #desk-tools-toggle {display:inline-flex;font:600 13px/1.3 "Malgun Gothic",system-ui,sans-serif}
#topbar #desk-tools-toggle {anchor-name:--desk-utilities}
#pomo-clock {font-variant-numeric:tabular-nums;color:var(--accent)}
#desk-utilities {
  position:fixed;inset:48px 12px auto auto;margin:0;padding:4px;width:190px;
  background:var(--bg2);color:var(--fg);border:1px solid var(--line);box-shadow:0 4px 14px #30203c29;
}
@supports(top:anchor(bottom)){
  #desk-utilities {position-anchor:--desk-utilities;inset:auto;top:anchor(bottom);right:anchor(right);margin-top:3px}
}
#desk-utilities button:not(.tauri-only),body.tauri #desk-utilities #btn-pin {display:flex}
#desk-utilities button,#desk-utilities #btn-auth {
  width:100%;min-height:var(--action-height);height:auto;align-items:center;justify-content:start;
  margin:0;padding:4px 12px;text-align:left;border:0;border-radius:1px;background:var(--bg2);color:var(--fg);font:inherit;
}
#desk-utilities button:hover,#desk-utilities #btn-auth:hover {background:var(--accent-soft);color:var(--highlight)}
#desk-utilities #btn-auth {border-top:1px solid var(--line)}
#desk-utilities #btn-pin[aria-pressed=true]::after {content:"✓";margin-left:auto}
.page-heading {display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px;margin-bottom:18px}
.page-heading h1,#view-study .desk-title h1 {margin:0;color:var(--fg);font-size:clamp(1.45rem,2.4vw,1.85rem);line-height:1.25;letter-spacing:-.055em}
#app :is(#view-events,#view-todo,#view-memo,#view-log,#view-study) {padding:20px var(--page-gutter);max-width:1120px}
#app :is(#view-events,#view-todo,#view-memo,#view-log) .row {gap:8px}
#app :is(#view-events,#view-todo,#view-memo,#view-log) :is(input:not([type=checkbox]),select),
#app :is(#quick-add,#deadline-form,#todo-form,#memo-form,#log-form,#search-bar,#range-toggle,#ev-month-nav,#log-nav) button,
#app #study-open-day,#app .connection-note button {
  box-sizing:border-box;min-height:var(--action-height);border-radius:2px;font-size:13px;line-height:1.35;
}
#app :is(#quick-add,#deadline-form,#todo-form,#memo-form,#log-form,#search-bar) button[type=submit] {
  flex:0 0 auto;width:auto;min-width:72px;padding-inline:12px;background:var(--accent);
  color:var(--accent-ink);border:1px solid var(--accent);font-weight:650;white-space:nowrap;
}
#range-toggle {display:inline-flex;gap:2px;margin:0;padding:2px;background:var(--bg3);border-radius:2px}
#range-toggle .rbtn {flex:none;width:auto;min-width:56px;padding:0 10px;border:0;background:transparent}
#range-toggle .rbtn.active {background:var(--bg2);color:var(--highlight);box-shadow:inset 0 -2px var(--accent)}
#view-events.showing-search :is(#quick-add,#range-toggle,#deadline-add) {display:none}
#app :is(#todo-form,#memo-form,#log-form,#quick-add) {margin:0 0 14px}
#app :is(#todo-form,#log-form) input:not([type=checkbox]) {flex:1;min-width:0}
#app #memo-text {min-height:88px;resize:vertical;padding:10px 12px;line-height:1.6;border-radius:2px}
#app #memo-project {flex:0 1 260px}
#memo-form .row {justify-content:space-between}
#app :is(#ev-month-nav,#log-nav) {gap:12px;justify-content:center;margin:8px 0 12px}
#app :is(#ev-month-nav,#log-nav) button {width:var(--action-height);padding:0;font-weight:650;font-size:19px}
#app #ev-more>summary,#app #deadline-add>summary {display:list-item;min-height:var(--action-height);align-content:center;padding:6px 0;cursor:pointer}
#app .connection-note {margin:12px 0;padding:12px 14px;background:var(--bg2);border-inline-start:3px solid var(--rule);color:var(--fg-dim);font-size:13px;line-height:1.6}
#app .connection-note button {margin-inline-start:6px;padding:0 10px}
#log-calendar:empty,#log-stats:empty {display:none}
#app #log-calendar .cal-cell {aspect-ratio:auto;min-height:clamp(40px,6.2vh,62px);border-radius:1px}
#app #search-bar:not([hidden]) {display:flex;gap:8px;padding:8px var(--page-gutter);align-items:center;background:var(--bg2)}
#search-bar input {min-width:0;flex:1;min-height:var(--action-height)}
#search-close {width:var(--action-height)}
#app #view-study :is(.study-card button,.desk-dates button,.desk-dates input,.study-card select,.study-card input:not([type=checkbox],[type=range],[type=file])),
#app #view-study #night-room :is(#study-subject,#study-task-input,#study-start,#study-stop,#study-task button) {
  min-height:var(--action-height);box-sizing:border-box;border-radius:2px;font-size:13px;line-height:1.35;
}
#view-study .study-card :is(button,input,select) {max-width:100%}
#app #view-study .study-card :is(form,.ambient-controls) {gap:8px}
#view-study .study-card details > summary,.desk-tools .study-card > summary {min-height:var(--action-height);align-content:center;cursor:pointer}
#app #view-study #night-room #study-carry {min-height:30px;font-size:12px;margin-top:3px}
#view-study .desk-dates {gap:8px}
#app #view-study #desk-settings,#app #view-study #desk-backup {scroll-margin-block:12px}
#app #view-study :is(.studio,.desk-tools) label {margin-top:6px}
#app #view-study .study-card :is(#study-export,#playlist-save,#study-note button,#study-alarm button) {background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
#tabs .desk-pages .tab,#tabs .desk-shortcuts button {min-height:var(--action-height)}
@media(min-width:760px){
  #tabs .desk-pages,#tabs .desk-shortcuts {gap:4px}
  #app :is(#view-todo,#view-memo,#view-log) {max-width:940px}
}
@media(max-width:759px){
  #app {--action-height:44px;--page-gutter:12px}
  #topbar {min-height:48px;padding:2px 6px;gap:4px}
  #topbar .top-actions {gap:2px}
  #topbar .top-actions > button {padding-inline:6px}
  #app :is(#view-events,#view-todo,#view-memo,#view-log,#view-study) {padding-block:14px}
  .page-heading {margin-bottom:12px}
  #app #ev-more .row,#app #deadline-form .row {flex-wrap:wrap}
  #app #ev-more input,#app #deadline-form input {flex:1 1 100px}
  #app #search-bar:not([hidden]) {padding:5px 8px}
  #app #range-toggle {gap:1px}
  #range-toggle .rbtn {min-width:44px;padding-inline:7px}
  #app #view-study #night-room {min-width:0}
  #app #view-study .desk-dates {gap:4px}
  #app #view-study .scene-timer {gap:6px}
  #app #view-study #study-timer input {width:0}
  #app #view-study #study-timer button {white-space:nowrap}
}
@media(max-width:420px){
  #app #range-toggle .rbtn {min-width:42px}
  .desk-title {flex-wrap:wrap}
  .desk-totals div {padding:6px}
}
#calendar-connect {display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px}
#calendar-connect p {margin:0}
#app #calendar-connect #btn-login-cta {margin:0;padding:0 12px;border:1px solid var(--line);border-radius:2px;background:var(--bg2);color:var(--accent);box-shadow:none}
#app:has(#btn-auth.connected) #calendar-connect,#view-events.showing-search #calendar-connect {display:none}
#desk-tool-heading[hidden] {display:none}
#desk-tool-back {min-height:var(--action-height);padding:0 12px;border:1px solid var(--line);background:var(--bg2);color:var(--fg)}
#view-study[data-tool] > :not(#desk-tool-heading):not(.desk-columns):not(.desk-tools):not(#study-feedback),
#view-study[data-tool]:not([data-tool="music-heading"]) > .desk-columns,
#view-study[data-tool="music-heading"] :is(.desk-tools,.desk-primary,.weekly-card,#companion-home,#music-heading),
#view-study[data-tool="desk-settings"] #desk-backup,#view-study[data-tool="desk-backup"] #desk-settings,
#view-study[data-tool] .desk-tools > details > summary {display:none}
#view-study[data-tool] :is(.desk-tools,.desk-columns,.desk-secondary) {display:block;margin:0;padding:0;border:0}
#view-study[data-tool] :is(.studio,#desk-settings,#desk-backup) {max-width:680px;margin:0;padding:16px;border:1px solid var(--line);background:var(--bg2)}
#view-study[data-tool] #music-queue-panel audio {width:100%}
#tabs [data-study-target][aria-current=page] {background:var(--paper);box-shadow:inset 3px 0 var(--accent);font-weight:700}
#app:has(#view-study[data-tool]) #tabs .tab[data-view=study] {background:transparent;box-shadow:none}
@media(min-width:760px){#desk-utilities [data-study-target] {display:none!important}}
