:root {
  --face: #c0c0c0;
  --out: inset -1px -1px #000, inset 1px 1px #fff, inset -2px -2px #808080, inset 2px 2px #dfdfdf;
  --in: inset -1px -1px #fff, inset 1px 1px #808080, inset -2px -2px #dfdfdf, inset 2px 2px #000;
}
* { box-sizing: border-box; border-radius: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  display: grid;
  place-items: center;
  height: 100dvh;
  background: #008080;
  color: #000;
  font: 14px/1.4 'MS Sans Serif', 'Microsoft Sans Serif', Tahoma, Geneva, Verdana, sans-serif;
}
button, input { font: inherit; color: inherit; }
p { margin: 0; }
.window { padding: 4px; border: 0; background: var(--face); color: #000; box-shadow: var(--out); }
#window { display: flex; flex-direction: column; width: min(640px, calc(100vw - 24px)); height: min(480px, calc(100dvh - 24px)); }
#window.max { width: 100vw; height: 100dvh; }
#window.min { height: auto; }
#window.min > :not(.title) { display: none; }

.title { display: flex; align-items: center; gap: 2px; height: 24px; padding: 0 3px; background: #000080; color: #fff; }
.title h1 { flex: 1; margin: 0 0 0 3px; font-size: 14px; font-weight: 700; }
.title button { position: relative; width: 19px; height: 17px; padding: 0; border: 0; background: var(--face); box-shadow: var(--out); color: #000; }
.title button:active:enabled { box-shadow: var(--in); }
#min::after { content: ''; position: absolute; left: 5px; bottom: 4px; width: 7px; height: 2px; background: #000; }
#max::after { content: ''; position: absolute; inset: 3px 4px 4px; border: 1px solid #000; border-top-width: 2px; }
.x::before, .x::after { content: ''; position: absolute; left: 4px; top: 7px; width: 11px; height: 2px; background: #000; transform: rotate(45deg); }
.x::after { transform: rotate(-45deg); }

.menubar { position: relative; padding: 2px 0; }
.menubar button { display: block; padding: 2px 8px; border: 0; background: none; }
#menu[aria-expanded='true'], #dropdown button:hover, #dropdown button:focus-visible { background: #000080; color: #fff; }
#dropdown { position: absolute; z-index: 1; top: 100%; left: 0; width: min(300px, 100%); padding: 3px; background: var(--face); box-shadow: var(--out); }
#dropdown button { width: 100%; overflow: hidden; padding: 4px 8px 4px 22px; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
#chats { max-height: 240px; overflow-y: auto; margin: 3px 0; padding: 3px 0; border-block: 1px solid #808080; box-shadow: 0 1px #fff, inset 0 1px #fff; }
#chats:empty { display: none; }
#chats [aria-current='true'] { position: relative; }
#chats [aria-current='true']::before { content: '✓'; position: absolute; left: 6px; }

#log { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; background: #fff; box-shadow: var(--in); font-size: 15px; }
.row { overflow-wrap: anywhere; white-space: pre-wrap; }
.row + .row { margin-top: 3px; }
.row b { color: #a00000; }
.row.mine b { color: #000080; }
.oops { margin-top: 3px; color: #a00000; }
.oops button { margin-left: 6px; }

.button { min-width: 75px; padding: 4px 10px; border: 0; background: var(--face); box-shadow: var(--out); }
.button:active:enabled { box-shadow: var(--in); }
.button:disabled { color: #808080; text-shadow: 1px 1px #fff; }
.button:focus-visible { outline: 1px dotted #000; outline-offset: -5px; }
#log:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }
#composer { display: flex; gap: 4px; padding-top: 4px; }
input { flex: 1; min-width: 0; padding: 5px 7px; border: 0; outline: 0; background: #fff; box-shadow: var(--in); }

dialog { width: min(300px, calc(100vw - 24px)); }
dialog::backdrop { background: none; }
dialog form { display: grid; gap: 8px; padding: 12px; }
dialog .button { justify-self: center; }
#problem:empty { display: none; }

/* iOS zooms into inputs under 16px. */
@media (pointer: coarse) {
  input { font-size: 16px; }
  .menubar button, .button { min-height: 36px; }
  .title { height: 34px; }
  .title button { width: 30px; height: 28px; }
  #min::after { left: 11px; bottom: 8px; }
  #max::after { inset: 8px 9px; }
  .x::before, .x::after { left: 9px; top: 13px; }
}
@media (max-width: 560px) { #window { width: 100vw; height: 100dvh; } }
