:root {
  --ink: #111;
  --paper: #fff;
  --grey: #c0c0c0;
  --dark: #808080;
  --red: #d9402b;
  --link: #0000cc;
  --sky: #b7d5f3;
  --font: "DotGothic16", "MS Gothic", "Osaka-Mono", ui-monospace, monospace;
  --bar: 24px;
  --task: 34px;
}
* { box-sizing: border-box; }
html { scroll-behavior: auto; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  /* classic 2px dither */
  background: repeating-conic-gradient(var(--paper) 0% 25%, var(--sky) 0% 50%) 0 0 / 4px 4px;
  padding-bottom: var(--task);
  -webkit-font-smoothing: none;
}
a { color: var(--link); }
button { font-family: inherit; }

/* ---------- menu bar ---------- */
#menubar {
  position: sticky; top: 0; z-index: 9000;
  height: var(--bar); display: flex; align-items: center; gap: 4px;
  background: var(--paper); border-bottom: 2px solid var(--ink); padding: 0 6px;
}
.mb-item { padding: 0 8px; font-size: 13px; background: none; border: 0; color: var(--ink); line-height: var(--bar); }
.mb-brand { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.mb-brand:hover { background: var(--ink); color: var(--paper); }
.mb-logo { display: inline-grid; place-items: center; width: 16px; height: 16px; background: var(--red); color: #fff; font-size: 12px; line-height: 1; }
.mb-right { margin-left: auto; font-size: 12px; color: #555; }

/* ---------- desktop ---------- */
#desktop { position: relative; min-height: calc(100vh - var(--bar) - var(--task)); overflow-x: clip; }
#icons { position: absolute; left: 8px; top: 14px; width: 92px; display: grid; gap: 10px; z-index: 1; }
.icon {
  display: grid; justify-items: center; gap: 4px; width: 92px; padding: 4px 0;
  background: none; border: 0; color: var(--ink); cursor: pointer; text-align: center; font-size: 12px; line-height: 1.2;
}
.icon svg { width: 40px; height: 40px; shape-rendering: crispEdges; }
.icon .lbl { padding: 1px 4px; background: var(--paper); border: 1px solid var(--ink); max-width: 88px; overflow-wrap: anywhere; }
.icon.sel .lbl, .icon:focus-visible .lbl { background: var(--ink); color: var(--paper); }
.icon:focus-visible { outline: none; }

/* ---------- windows ---------- */
.win {
  position: absolute; background: var(--paper); border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}
.win[hidden] { display: none; }
.titlebar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 2px 3px 2px 8px; background: var(--c, #ccc); border-bottom: 2px solid var(--ink);
  cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none; font-size: 14px;
}
.titlebar:active { cursor: grabbing; }
.win:not(.active) .titlebar { filter: saturate(.55) brightness(1.08); }
.ttl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btns { display: flex; gap: 3px; flex: none; }
.btns button {
  width: 20px; height: 18px; padding: 0; display: grid; place-items: center;
  border: 2px solid var(--ink); background: var(--paper); color: var(--ink); font-size: 14px; line-height: 1; cursor: pointer;
}
.btns button:hover { background: var(--ink); color: var(--paper); }
.menu { display: flex; gap: 14px; padding: 2px 8px; font-size: 12px; border-bottom: 1px solid #999; user-select: none; }
.content { padding: 10px; }
.content p { margin: 0; }

.shot { display: block; border: 2px solid var(--ink); line-height: 0; background: #000; }
.shot img { width: 100%; height: auto; display: block; }
.shot:hover, .shot:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.kv { margin-top: 8px !important; font-size: 13px; }
.kv b { color: #666; font-weight: normal; }
.sep { border: 0; border-top: 1px dashed var(--ink); margin: 8px 0; }
.tagline { color: var(--link); }
.desc { margin-top: 6px !important; font-size: 13px; }
.tags { margin-top: 6px !important; margin-bottom: 10px !important; font-size: 12px; color: #666; }

.btn {
  display: inline-block; padding: 3px 14px; background: var(--grey); color: var(--ink); text-decoration: none; font-size: 13px; cursor: pointer;
  border: 2px solid; border-color: #fff #000 #000 #fff; box-shadow: inset -1px -1px 0 var(--dark), inset 1px 1px 0 #dfdfdf;
}
.btn:active { border-color: #000 #fff #fff #000; box-shadow: inset 1px 1px 0 var(--dark); }
.btn:focus-visible { outline: 1px dotted var(--ink); outline-offset: -5px; }

/* about */
.about .kanji { font-size: 28px; color: var(--red); line-height: 1; }
.about h1 { margin: 6px 0 10px; font-size: 30px; font-weight: normal; line-height: 1.1; letter-spacing: -.5px; }
.about h1 span { background: var(--ink); color: var(--paper); padding: 0 6px; }
.about p + p { margin-top: 8px; }
.about .stats { margin-top: 12px; padding-top: 8px; border-top: 1px dashed var(--ink); font-size: 12px; color: #555; }

/* clock */
.clock-wrap { display: grid; justify-items: center; gap: 8px; }
.clock-wrap svg { width: 150px; height: 150px; shape-rendering: crispEdges; }
.face { fill: #fff; stroke: var(--ink); stroke-width: 3; }
.tick { stroke: #999; stroke-width: 1; }
.tick.major { stroke: var(--ink); stroke-width: 3; }
.hand { transform-origin: 100px 100px; stroke-linecap: square; }
.hand-h { stroke: var(--ink); stroke-width: 6; }
.hand-m { stroke: var(--ink); stroke-width: 4; }
.hand-s { stroke: var(--red); stroke-width: 2; }
.pin { fill: var(--red); }
.digital { width: 100%; text-align: center; padding: 2px 6px; font-size: 18px; background: #e8f0d0; border: 2px solid; border-color: #808080 #fff #fff #808080; font-variant-numeric: tabular-nums; }

/* assistant */
.assistant { display: flex; gap: 12px; align-items: flex-start; }
.wiz { font-size: 44px; line-height: 1; flex: none; }
.assistant p { font-size: 13px; margin-bottom: 10px !important; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- taskbar ---------- */
#taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9500; height: var(--task);
  display: flex; align-items: center; gap: 6px; padding: 3px 4px;
  background: var(--grey); border-top: 2px solid #fff; box-shadow: 0 -1px 0 var(--ink);
}
#start, .task {
  height: 100%; display: flex; align-items: center; gap: 6px; padding: 0 10px; color: var(--ink); background: var(--grey); cursor: pointer;
  border: 2px solid; border-color: #fff #000 #000 #fff; box-shadow: inset -1px -1px 0 var(--dark);
  font-size: 13px;
}
#start .logo { display: inline-grid; place-items: center; width: 18px; height: 18px; background: var(--red); color: #fff; font-size: 12px; line-height: 1; }
#start[aria-expanded="true"], .task.on { border-color: #000 #fff #fff #000; box-shadow: inset 1px 1px 0 var(--dark); background: repeating-conic-gradient(#fff 0% 25%, var(--grey) 0% 50%) 0 0 / 2px 2px; }
#tasks { display: flex; gap: 4px; flex: 1; min-width: 0; overflow: hidden; height: 100%; }
.task { min-width: 0; max-width: 170px; flex: 0 1 170px; }
.task span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tray { height: 100%; display: flex; align-items: center; padding: 0 10px; font-size: 13px; border: 2px solid; border-color: #808080 #fff #fff #808080; }

#startmenu {
  position: fixed; left: 4px; bottom: calc(var(--task) + 2px); z-index: 9600; width: 250px; display: flex;
  background: var(--grey); border: 2px solid; border-color: #fff #000 #000 #fff; box-shadow: 3px 3px 0 var(--ink);
}
#startmenu[hidden] { display: none; }
.sm-side { flex: none; width: 28px; background: var(--ink); color: #fff; display: flex; align-items: flex-end; justify-content: center; padding: 8px 0; }
.sm-side span { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 18px; letter-spacing: 2px; }
#sm-list { list-style: none; margin: 0; padding: 2px; flex: 1; max-height: 70vh; overflow: auto; }
#sm-list button {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; background: none; border: 0; color: var(--ink); font-size: 13px; text-align: left; cursor: pointer;
}
#sm-list button:hover, #sm-list button:focus-visible { background: var(--red); color: #fff; outline: none; }
#sm-list .dot { width: 10px; height: 10px; border: 1px solid var(--ink); background: var(--c, #ccc); flex: none; }
#sm-list li.rule { border-top: 1px solid var(--dark); border-bottom: 1px solid #fff; margin: 3px 2px; }

/* ---------- small screens: windows stack, no dragging ---------- */
#desktop.stack #icons { position: static; width: auto; display: flex; flex-wrap: wrap; gap: 4px; padding: 10px 8px 0; }
#desktop.stack .win { position: static; width: auto !important; margin: 14px 10px; box-shadow: 3px 3px 0 var(--ink); }
#desktop.stack .titlebar { cursor: default; touch-action: auto; }
#desktop.stack { min-height: 0; }

@media (max-width: 759px) {
  #tasks { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
