/* Desktop edition (plan: coding-plan/desktop-edition.md D2). Same markup as the phone; every rule that changes an existing part of the
   page sits inside a min-width (or installed-window) media query, so a phone (390 px) looks exactly as before.
   900 px and up: the tab bar becomes a rail on the left, the word look-up opens as a side panel instead of a bottom sheet.
   1280 px and up: a wider column, the reading text capped at about 42 Japanese characters a line, and the side panel beside the text. */
/* min-height keeps big phones held sideways (about 932 x 430) on the phone layout */
@media (min-width:900px) and (min-height:500px){
  :root{--railw:calc(88px + env(safe-area-inset-left,0px));--lkw:min(400px,36vw)}
  /* tab bar -> left rail (same buttons, role=tablist, aria-selected) */
  body.hastabs{padding-left:calc(var(--railw) + 24px);padding-right:max(24px,env(safe-area-inset-right,0px))}
  .tabbar{top:0;right:auto;bottom:0;width:var(--railw);flex-direction:column;justify-content:flex-start;gap:4px;border-top:0;border-right:1px solid var(--rule);box-shadow:none;padding:calc(12px + env(safe-area-inset-top,0px)) 0 calc(12px + env(safe-area-inset-bottom,0px)) env(safe-area-inset-left,0px);overflow-y:auto;box-sizing:border-box}
  .tabbar button{flex:0 0 auto;padding:10px 4px;gap:3px;border-top:0;border-left:3px solid transparent}
  .tabbar button[aria-selected=true]{border-left-color:var(--ai);background:var(--ai-soft)}
  .tabbar button:hover{color:var(--ink)}
  .tabbar button i{font-size:22px}
  .tabbar button span{font-size:12px;white-space:normal;text-align:center;overflow-wrap:anywhere}
  body.hastabs #app{padding-bottom:120px}
  body.hastabs #player{bottom:0;left:var(--railw);padding-bottom:calc(8px + env(safe-area-inset-bottom,0px))}
  .wrap{max-width:46rem}
  /* word look-up: side panel on the right */
  .lk-sheet,body.hastabs .lk-sheet{left:auto;right:0;top:0;bottom:0;width:var(--lkw);max-height:none;border-top:0;border-left:3px solid var(--ai);box-shadow:-4px 0 16px rgba(0,0,0,.18);padding:calc(16px + env(safe-area-inset-top,0px)) max(20px,env(safe-area-inset-right,0px)) 20px 20px}
  .lk-word{font-size:26px}
  body.lk-open #app,body.hastabs.lk-open #app{padding-bottom:120px}
  body.lk-open #player{right:var(--lkw)}
  /* flashcards and dialogs keep a comfortable size */
  .dcard{max-width:40rem;margin-left:auto;margin-right:auto}
}
@media (min-width:1280px) and (min-height:500px){
  .wrap{max-width:52rem}
  /* reading measure: about 42 Japanese characters (ic = one ideograph) or a comfortable Latin line */
  .story p{max-width:44em;max-width:42ic}
  .story:lang(fr) p,.story:lang(en) p,.story:lang(ko) p{max-width:36em}
  /* the panel sits beside the text instead of over it */
  body.lk-open .wrap{margin-right:var(--lkw);margin-left:max(0px,calc((100% - 52rem - var(--lkw)) / 2))}
}
/* a mouse: words show they can be clicked (the click stays the way in; "Look up on hover" in Settings adds hover, off by default) */
@media (min-width:600px) and (hover:hover) and (pointer:fine){
  .story .mw:hover{text-decoration:underline dotted var(--ai);text-underline-offset:.35em}
}
/* installed window with the title bar hidden (window-controls-overlay): keep the app below the window buttons, drag by the top strip */
@media (display-mode:window-controls-overlay){
  body::before{height:env(titlebar-area-height,0px);-webkit-app-region:drag;app-region:drag}
  .wrap{padding-top:env(titlebar-area-height,0px)}
  .bar{top:env(titlebar-area-height,0px)}
}
@media (display-mode:window-controls-overlay) and (min-width:900px) and (min-height:500px){
  .tabbar,.lk-sheet,body.hastabs .lk-sheet{top:env(titlebar-area-height,0px)}
}
/* keyboard shortcuts list ("?", keys.js): only exists while it is open */
.ks-back{position:fixed;inset:0;z-index:95;background:rgba(0,0,0,.45);display:flex;align-items:flex-start;justify-content:center;overflow:auto;padding:6vh 14px 14px;box-sizing:border-box}
.ks-back[hidden]{display:none}
.ks-sheet{background:var(--slip);color:var(--ink);border-top:3px solid var(--ai);border-radius:8px;box-shadow:0 6px 24px rgba(0,0,0,.3);width:100%;max-width:30rem;padding:14px 20px 16px;box-sizing:border-box}
.ks-head{display:flex;align-items:center;gap:10px}.ks-head h2{flex:1;font-size:19px;margin:0}
.ks-sheet h3{font-size:13px;color:var(--muted);margin:14px 0 4px;font-weight:600}
.ks-list{margin:0}.ks-list div{display:flex;gap:12px;align-items:baseline;padding:5px 0;border-top:1px solid var(--rule)}.ks-list div:first-child{border-top:0}
.ks-list dt{min-width:5.5em}.ks-list dd{margin:0;font-size:14px}
.ks-sheet kbd{font:inherit;font-size:13px;font-weight:600;border:1px solid var(--rule);border-bottom-width:2px;border-radius:5px;padding:1px 7px;background:var(--paper)}
.ks-x:focus-visible{outline:2px solid var(--ai);outline-offset:1px}
/* "Update ready" bar (sw-register.js): only exists when a new version waits */
.upd-bar{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(14px + env(safe-area-inset-bottom,0px));z-index:65;display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px;max-width:calc(100% - 28px);box-sizing:border-box;background:var(--slip);color:var(--ink);border:1px solid var(--ai);border-radius:12px;box-shadow:0 4px 16px rgba(0,0,0,.22);padding:8px 12px;font-size:14px}
.upd-bar[hidden]{display:none}
.upd-bar .upd-text{font-weight:600;margin-right:4px}
.upd-bar .btn:focus-visible{outline:2px solid var(--ai);outline-offset:2px}
body.hastabs .upd-bar{bottom:calc(var(--tabh) + 12px + env(safe-area-inset-bottom,0px))}
/* with the audio player showing, the bar moves to the top so it never covers the player's controls */
#player:not([hidden]) ~ .upd-bar{top:calc(var(--barh,42px) + 10px + env(safe-area-inset-top,0px));bottom:auto}
@media (min-width:900px) and (min-height:500px){
  body.hastabs .upd-bar{bottom:16px;margin-left:calc(var(--railw) / 2)}
  body.hastabs #player:not([hidden]) ~ .upd-bar{bottom:auto}
  /* with the look-up side panel open the bar is centred between the rail and the panel, and never sits under the panel */
  .upd-bar{z-index:72}
  body.lk-open .upd-bar{margin-left:calc((var(--railw,0px) - var(--lkw)) / 2);max-width:calc(100% - var(--railw,0px) - var(--lkw) - 28px)}
}
/* installed window with the title bar hidden: the bar at the top stays below the window-buttons strip */
@media (display-mode:window-controls-overlay){
  #player:not([hidden]) ~ .upd-bar{top:calc(env(titlebar-area-height,0px) + var(--barh,42px) + 10px)}
}
