/* KaiOS 98: a pretend Windows-98-era desktop from an internet cafe, run by Kai. Pure CSS bevels, same-origin icons, no inline styles. */
:root { --face: #c0c0c0; --hi: #fff; --lo: #808080; --dk: #000; --title1: #000080; --title2: #1084d0; --desk: #008080; --text: #000; --link: #0000c8; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 12px/1.35 Tahoma, "MS Sans Serif", Verdana, Geneva, sans-serif; color: var(--text); background: var(--desk); overflow: hidden; }
body.page { overflow: auto; }
a { color: var(--link); }
img { image-rendering: pixelated; }
button { font: inherit; }
.bevel { background: var(--face); border: 2px solid; border-color: var(--hi) var(--dk) var(--dk) var(--hi); box-shadow: inset -1px -1px var(--lo), inset 1px 1px #dfdfdf; }
.sunk { background: #fff; border: 2px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo); box-shadow: inset 1px 1px var(--dk); }
.b95 { font: 12px Tahoma, sans-serif; background: var(--face); color: var(--text); border: 2px solid; border-color: var(--hi) var(--dk) var(--dk) var(--hi); box-shadow: inset -1px -1px var(--lo), inset 1px 1px #dfdfdf; padding: 3px 14px; min-height: 23px; cursor: pointer; }
.b95:active, .b95.on { border-color: var(--dk) var(--hi) var(--hi) var(--dk); box-shadow: inset 1px 1px var(--lo); padding: 4px 13px 2px 15px; }
.b95:focus-visible { outline: 1px dotted var(--dk); outline-offset: -5px; }

/* boot screen */
.boot { position: fixed; inset: 0; z-index: 9000; background: #000; color: #c0c0c0; font: 14px/1.5 "Courier New", monospace; padding: 24px; white-space: pre-wrap; cursor: pointer; }
.boot.done { display: none; }
.boot b { color: #fff; }
.boot .logo { color: #fff; font-size: 22px; margin: 18px 0 6px; }
.boot .bar { width: 280px; height: 18px; border: 2px solid var(--lo); padding: 2px; margin-top: 8px; }
.boot .bar i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(90deg, #0000a8 0 10px, #000 10px 13px); }

/* desktop */
.desk { position: fixed; inset: 0 0 30px 0; overflow: hidden; background: var(--desk); }
.icons { position: absolute; left: 10px; top: 10px; bottom: 10px; display: flex; flex-direction: column; flex-wrap: wrap; gap: 6px 8px; align-content: flex-start; }
.ico { width: 82px; text-align: center; color: #fff; text-decoration: none; padding: 3px 2px; background: none; border: 1px solid transparent; cursor: pointer; display: block; text-shadow: 1px 1px 0 #000; }
.ico img { width: 32px; height: 32px; display: block; margin: 0 auto 3px; }
.ico span { display: block; word-break: break-word; }
.ico:hover span, .ico:focus-visible span, .ico.sel span { background: var(--title1); outline: 1px dotted #fff; }
.mark { position: absolute; right: 14px; bottom: 12px; text-align: right; color: #bfeeee; font: bold 26px "Times New Roman", serif; text-shadow: 2px 2px 0 #004a4a; pointer-events: none; user-select: none; }
.mark small { display: block; font: 11px Tahoma, sans-serif; letter-spacing: 1px; }

/* windows */
.win { position: absolute; min-width: 240px; max-width: 100vw; display: flex; flex-direction: column; background: var(--face); border: 2px solid; border-color: #dfdfdf var(--dk) var(--dk) #dfdfdf; box-shadow: inset -1px -1px var(--lo), inset 1px 1px var(--hi), 3px 3px 0 rgba(0, 0, 0, .35); padding: 2px; }
.win[hidden] { display: none; }
.win.max { inset: 0 !important; width: auto !important; height: auto !important; box-shadow: none; }
.tbar { display: flex; align-items: center; gap: 4px; padding: 2px 3px; color: #fff; font-weight: bold; background: linear-gradient(90deg, var(--title1), var(--title2)); user-select: none; touch-action: none; cursor: default; }
.win:not(.focus) .tbar { background: linear-gradient(90deg, #808080, #b0b0b0); }
.tbar img { width: 16px; height: 16px; }
.tbar .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbar button { width: 18px; height: 16px; padding: 0; line-height: 1; font: bold 10px Tahoma, sans-serif; color: #000; background: var(--face); border: 2px solid; border-color: var(--hi) var(--dk) var(--dk) var(--hi); box-shadow: inset -1px -1px var(--lo); cursor: pointer; }
.tbar button:active { border-color: var(--dk) var(--hi) var(--hi) var(--dk); }
.menubar { display: flex; gap: 12px; padding: 2px 6px; border-bottom: 1px solid var(--lo); }
.menubar span { cursor: default; }
.body { flex: 1; overflow: auto; padding: 8px; margin: 2px; background: #fff; border: 2px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo); box-shadow: inset 1px 1px var(--dk); min-height: 80px; }
.body.grey { background: var(--face); }
.status { display: flex; gap: 2px; padding: 2px; font-size: 11px; }
.status span { flex: 1; padding: 1px 6px; border: 1px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo); }
.win h1 { font-size: 16px; margin: 0 0 6px; } .win h2 { font-size: 13px; margin: 10px 0 4px; }
.win p { margin: 0 0 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 6px; }
.grid .ico { color: #000; text-shadow: none; }
.grid .ico:hover span, .grid .ico:focus-visible span { color: #fff; }

/* controls inside windows */
.tool label { display: block; font-weight: bold; margin: 8px 0 2px; }
.tool input[type=text], .tool input[type=number], .tool input[type=date], .tool textarea, .tool select, .field { width: 100%; max-width: 360px; font: 12px Tahoma, sans-serif; padding: 3px 4px; background: #fff; border: 2px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo); box-shadow: inset 1px 1px var(--dk); color: #000; }
.tool textarea { min-height: 62px; max-width: 100%; }
.result { margin-top: 10px; padding: 8px; background: #ffffe1; border: 1px solid var(--dk); min-height: 28px; overflow-wrap: anywhere; }
.big { display: block; font: bold 36px "Times New Roman", serif; color: var(--title1); text-align: center; }
.out { font: 14px "Courier New", monospace; background: #fff; border: 2px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo); padding: 3px 5px; margin: 4px 0; word-break: break-all; }
.msg { font-weight: bold; color: #a00000; min-height: 16px; }
.caro { display: grid; grid-template-columns: repeat(15, 1fr); width: 100%; max-width: 420px; background: #f7e9b6; border: 2px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo); touch-action: manipulation; }
.caro button { aspect-ratio: 1; padding: 0; border: 1px solid #c9b568; background: transparent; font: bold 14px Verdana, sans-serif; line-height: 1; cursor: pointer; }
.caro button.x { color: #1558d6; } .caro button.o { color: #d6153b; } .caro button.last { background: #fff1a0; }
.cal { width: 100%; border-collapse: collapse; text-align: center; } .cal th { background: var(--face); } .cal td, .cal th { padding: 3px 0; } .cal td.today { background: var(--title1); color: #fff; font-weight: bold; }
.digits { display: flex; gap: 2px; justify-content: center; margin: 6px 0; } .digits b { background: #000; color: #00ff00; font: bold 18px "Courier New", monospace; padding: 1px 5px; border: 2px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo); }
.entry { margin: 0 0 8px; padding-bottom: 6px; border-bottom: 1px dotted var(--lo); } .entry h3 { margin: 0; font-size: 12px; color: var(--title1); } .entry small { color: #555; display: block; } .entry p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.soft { list-style: none; margin: 0; padding: 0; } .soft li { padding: 6px 2px; border-bottom: 1px dotted var(--lo); } .soft small { display: block; color: #444; }
.soft .stores a, .stores a { display: inline-block; margin: 3px 4px 0 0; padding: 1px 8px; text-decoration: none; color: #000; background: var(--face); border: 2px solid; border-color: var(--hi) var(--dk) var(--dk) var(--hi); }
.tag { display: inline-block; font-size: 9px; font-weight: bold; color: #fff; padding: 0 3px; margin-left: 4px; animation: blink 1s steps(2) infinite; } .tag.new { background: #c0006a; } .tag.hot { background: #d02a00; }
@keyframes blink { 50% { opacity: .35; } }
.trash li { font-family: "Courier New", monospace; font-size: 11px; padding: 3px 0; list-style: none; border-bottom: 1px dotted var(--lo); }
.chatlog { height: 230px; overflow: auto; margin-bottom: 6px; padding: 4px; font-size: 12px; }
.chatlog p { margin: 0 0 4px; overflow-wrap: anywhere; } .chatlog b.kai { color: #0000c8; } .chatlog b.you { color: #b00000; }
.chatrow { display: flex; gap: 4px; } .chatrow input { flex: 1; min-width: 0; } .chatrow .nickf { flex: 0 0 90px; max-width: 90px; } .chatcol .msg { margin-top: 3px; }
.poll label { display: block; margin: 2px 0; } .poll .bar { height: 8px; background: var(--title1); margin: 1px 0 4px; }
.themes { display: flex; gap: 6px; flex-wrap: wrap; }

/* taskbar and start menu */
.tray { position: fixed; z-index: 8000; left: 0; right: 0; bottom: 0; height: 30px; display: flex; align-items: center; gap: 4px; padding: 2px 3px; background: var(--face); border-top: 2px solid var(--hi); box-shadow: 0 -1px var(--lo); }
.tray .start { display: flex; align-items: center; gap: 4px; font-weight: bold; padding: 2px 8px 2px 4px; height: 24px; }
.tray .start img { width: 16px; height: 16px; }
.tasks { flex: 1; display: flex; gap: 3px; overflow: hidden; }
.tasks button { max-width: 150px; min-width: 40px; flex: 0 1 150px; height: 24px; padding: 0 6px; display: flex; align-items: center; gap: 4px; overflow: hidden; white-space: nowrap; text-align: left; }
.tasks img { width: 14px; height: 14px; }
.sys { display: flex; align-items: center; gap: 6px; padding: 2px 8px; height: 24px; border: 1px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo); }
.smenu { position: fixed; z-index: 8500; left: 2px; bottom: 30px; width: 230px; display: flex; padding: 2px; }
.smenu[hidden] { display: none; }
.smenu .side { width: 26px; background: linear-gradient(0deg, var(--title1), var(--title2)); color: #fff; font: bold 17px "Arial Black", Arial, sans-serif; writing-mode: vertical-rl; transform: rotate(180deg); padding: 6px 2px; letter-spacing: 1px; }
.smenu ul { list-style: none; margin: 0; padding: 0; flex: 1; }
.smenu li a, .smenu li button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; text-decoration: none; color: #000; background: none; border: 0; text-align: left; cursor: pointer; font-size: 12px; }
.smenu li a:hover, .smenu li button:hover, .smenu li a:focus-visible, .smenu li button:focus-visible { background: var(--title1); color: #fff; outline: 0; }
.smenu img { width: 24px; height: 24px; }
.smenu hr { border: 0; border-top: 1px solid var(--lo); border-bottom: 1px solid var(--hi); margin: 2px 0; }

/* Kai, the paperclip-style helper */
.helper { position: fixed; z-index: 7000; right: 14px; bottom: 44px; width: 240px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.helper[hidden] { display: none; }
.bubble { position: relative; background: #ffffe1; border: 1px solid #000; padding: 8px 10px 8px 10px; font-size: 12px; border-radius: 4px; box-shadow: 2px 2px 0 rgba(0, 0, 0, .3); }
.bubble::after { content: ""; position: absolute; right: 28px; bottom: -9px; border: 9px solid transparent; border-top-color: #000; border-bottom: 0; }
.bubble a { font-weight: bold; } .bubble .x { position: absolute; top: 1px; right: 4px; background: none; border: 0; cursor: pointer; font-weight: bold; }
.helper img { width: 56px; height: 56px; border: 2px solid #000; border-radius: 50%; background: #0b1730; cursor: pointer; image-rendering: auto; }

/* static (SEO) pages: one window centred on the desktop colour */
body.page { background: var(--desk); }
.sheet { max-width: 860px; margin: 18px auto 48px; }
.sheet .win { position: static; }
.sheet .body { min-height: 0; }
.sheet nav a { margin-right: 10px; }
.seo p { line-height: 1.55; }
@media (max-width: 720px) { .win:not(.max) { max-width: calc(100vw - 8px); } .icons { right: 6px; } .helper { width: 200px; } .mark { display: none; } }
@media (prefers-reduced-motion: reduce) { .tag { animation: none; } }

[hidden] { display: none !important; }
.w-readme { left: 110px; top: 14px; width: 470px; }
.helper .say { display: block; padding-right: 10px; }
.bubble .more { display: block; margin-top: 4px; }
body.theme-hong { --desk: #c0488f; } body.theme-hacker { --desk: #000; }
body.theme-hacker .mark { color: #00ff00; text-shadow: none; }
body.theme-hacker .desk .ico { color: #00ff00; }
.tray .b95.clock { min-height: 0; padding: 0 4px; border: 0; box-shadow: none; background: none; }
.sys .visits { font-size: 11px; }
.win .menubar a { color: inherit; text-decoration: none; }
.win .menubar a:hover { text-decoration: underline; }

/* Inputs must stay selectable and typeable everywhere (iOS blocks typing under user-select: none), and 16px stops iOS zooming on focus. */
input, textarea, select { -webkit-user-select: text; user-select: text; touch-action: manipulation; }
@media (max-width: 720px) { .tool input[type=text], .tool input[type=number], .tool input[type=date], .tool textarea, .tool select, .field { font-size: 16px; max-width: 100%; } }
