/* Itda web viewer — phone-first, works on any browser */
:root {
  --bg: #f4f3f9; --surface: #ffffff; --surface-2: #f0eff7; --line: #e1dfec;
  --fg: #19182b; --muted: #615f78; --accent: #4744b0; --accent-ink: #ffffff;
  --live: #0f9e90; --danger: #c42b1c; --coral: #ff6a43;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121120; --surface: #1d1c2e; --surface-2: #252439; --line: #302f47;
    --fg: #efeef8; --muted: #a3a1bd; --accent: #a4a1ff; --accent-ink: #17153d;
    --live: #33d1c2; --danger: #ff99a4;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
svg.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.screen { min-height: 100%; padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(16px, env(safe-area-inset-left)); }
.center { display: grid; place-items: center; }

/* login */
.login-card { width: min(360px, 100%); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-block: 24px; }
.login-logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 12px 32px rgba(38, 37, 95, .35); margin-bottom: 8px; }
.login-card h1 { margin: 0; font-size: 26px; letter-spacing: -.01em; }
.login-card p { margin: 0 0 14px; font-size: 14px; }
#loginForm { display: flex; flex-direction: column; gap: 10px; width: 100%; }
#pin { text-align: center; font-size: 26px; letter-spacing: .5em; padding: 12px 10px 12px calc(10px + .5em); border-radius: 12px; border: 1px solid var(--line); background: var(--surface); outline: none; }
#pin:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.primary { border: 0; border-radius: 12px; padding: 13px 16px; background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.error { color: var(--danger); font-size: 14px; min-height: 1.5em; }
#loginNote { margin: 4px 0 6px; padding: 10px 12px; border-radius: 12px; text-align: left; font-size: 14px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }
#loginForm button:disabled { opacity: .55; }

/* list */
.bar { display: flex; align-items: center; gap: 8px; padding: 14px 0 10px; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; font-size: 19px; }
.brand img { width: 32px; height: 32px; border-radius: 9px; }
.ghost { border: 0; background: transparent; padding: 8px; border-radius: 10px; color: var(--muted); display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; }
.ghost.text { padding: 8px 12px; font-size: 14px; }
.ghost:active { background: var(--surface-2); }
.hosts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 12px; padding-bottom: 24px; }
.host { display: flex; flex-direction: column; text-align: left; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.host:disabled { opacity: .55; cursor: default; }
.host .th { aspect-ratio: 16 / 10; background: linear-gradient(140deg, #4e4bba, #26255f); position: relative; display: grid; place-items: center; color: rgba(255,255,255,.85); }
.host .th img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.host .th svg.ic { width: 34px; height: 34px; }
.host .meta { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.host .meta b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.host .meta span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.host .meta span svg.ic { width: 13px; height: 13px; color: var(--live); flex: none; }
.host .meta span.warn { color: var(--danger); font-size: 12.5px; white-space: normal; }
.host .kind { font-size: 12px; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 48px 12px; }
div.host { position: relative; }
.host .open { all: unset; display: flex; flex-direction: column; cursor: pointer; min-width: 0; }
.host .open:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius); }
.host .th.windows { background: linear-gradient(140deg, #2b7bd8, #173f78); }
.host .th.mac { background: linear-gradient(140deg, #5d5d66, #26262c); }
.host .th.linux { background: linear-gradient(140deg, #c79a12, #5f4708); }
/* OS marks are filled; the penguin's belly and eyes are cut-outs in the tile's colour. */
svg.ic.osm { fill: currentColor; stroke: none; }
svg.ic.osm .cut { fill: var(--os-cut, #fff); }
.host .th.mac { --os-cut: #3d3d44; }
.host .th.linux { --os-cut: #8f6c0d; }
.chip.windows svg.ic { color: #0078d4; }
.chip.mac svg.ic { color: var(--fg, currentColor); }
.chip.linux svg.ic { color: #c79a12; }
.chip svg.ic.osm .cut { fill: var(--bg); }
.host .more { position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; border-radius: 10px; border: 0; display: grid; place-items: center;
  background: rgba(20, 19, 38, .55); color: #fff; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.host .more svg.ic { width: 17px; height: 17px; }
.host.add { align-items: center; justify-content: center; gap: 4px; min-height: 150px; border-style: dashed; background: transparent; color: var(--muted); padding: 16px; text-align: center; }
.host.add svg.ic { width: 28px; height: 28px; color: var(--accent); }
.host.add b { color: var(--fg); }
.host.add span { font-size: 13px; }

/* tabs, hint, accounts */
.tabs { display: flex; gap: 4px; padding: 3px; margin: 2px 0 14px; background: var(--surface-2); border-radius: 12px; width: fit-content; }
.tabs button { border: 0; background: transparent; min-height: 44px; padding: 7px 20px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 14px; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.hint { display: flex; align-items: center; gap: 8px; padding: 10px 6px 10px 14px; margin-bottom: 12px; border-radius: 12px; font-size: 13.5px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.hint span { flex: 1; }
.accounts { display: flex; flex-direction: column; gap: 8px; padding-bottom: 24px; max-width: 560px; }
.accounts .lead { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.acct { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-align: left; }
.acct .av { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 700; flex: none; }
.acct .who { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.acct .who small { color: var(--muted); font-size: 13px; }
.acct > svg.ic { color: var(--muted); width: 18px; height: 18px; }
.acct.add { border-style: dashed; background: transparent; color: var(--accent); justify-content: center; }

/* editor */
.editor { position: fixed; inset: 0; z-index: 20; background: rgba(10, 10, 22, .5); display: grid; place-items: center; padding: 16px; overflow: auto; }
.ed-card { width: min(440px, 100%); background: var(--surface); border-radius: 18px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 12px; }
.ed-card h2 { margin: 0 0 2px; font-size: 19px; }
.ed-card .note { margin: 0; font-size: 13.5px; color: var(--muted); }
.f { display: flex; flex-direction: column; gap: 5px; }
.f > span { font-size: 13px; font-weight: 600; }
.f i { font-style: normal; font-weight: 400; color: var(--muted); }
.f small { font-size: 12px; color: var(--muted); }
.f input, .f select { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font-size: 16px; outline: none; }
.f input:focus, .f select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
[data-own] { display: flex; flex-direction: column; gap: 12px; }
.seg { display: flex; padding: 3px; background: var(--surface-2); border-radius: 11px; gap: 3px; }
.seg label { flex: 1; }
.seg.four { display: grid; grid-template-columns: repeat(4, 1fr); }
.nearby { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.nearby b { font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px 7px 9px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); text-align: left; }
.chip svg.ic { width: 18px; height: 18px; color: var(--accent); }
.chip span { display: flex; flex-direction: column; line-height: 1.25; font-size: 13.5px; font-weight: 600; }
.chip small { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.chip.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
/* The Mac app's own window: a little more room, no browser chrome hints. */
body.local .bar { padding-top: 10px; }
@media (max-width: 420px) { .seg.four { grid-template-columns: repeat(2, 1fr); } }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 8px 6px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg input:checked + span { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }
.check small { display: block; color: var(--muted); font-size: 12px; }
.ed-actions { display: flex; gap: 8px; align-items: center; }
.ed-actions .grow { flex: 1; }
.ed-actions button { border: 0; border-radius: 11px; padding: 10px 16px; background: var(--surface-2); font-weight: 600; }
.ed-actions .primary { background: var(--accent); color: var(--accent-ink); }
.ed-actions .danger { background: transparent; color: var(--danger); padding-inline: 6px; }
.ed-actions button:disabled { opacity: .6; }
.ed-card .error:empty { display: none; }

/* viewer */
#view { padding: 0; background: #000; position: fixed; inset: 0; min-height: 0; overflow: hidden; }
#screen { position: absolute; inset: 0; }
#screen > div { background: #000 !important; }
.tools {
  position: absolute; z-index: 5; left: 50%; transform: translateX(-50%);
  top: max(8px, env(safe-area-inset-top));
  display: flex; gap: 2px; padding: 4px; border-radius: 14px;
  background: rgba(28, 27, 44, .82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 6px 22px rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.08);
  max-width: calc(100% - 16px); overflow-x: auto; scrollbar-width: none;
  transition: opacity .2s, transform .2s;
}
.tools.dim { opacity: .28; }
.tools button { border: 0; background: transparent; color: #f2f1fb; min-width: 48px; height: 50px; padding: 4px 4px 3px; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; flex: none; position: relative; }
.tools .tl { font-size: 10.5px; line-height: 1.2; white-space: nowrap; color: #c9c7df; }
.tools button.on .tl { color: inherit; }
/* The Mac app's window has tooltips and a pointer: icons only, as before. */
body.app .tools button { min-width: 42px; height: 40px; padding: 0; }
body.app .tools .tl { display: none; }
.tools button.on { color: #33d1c2; }
.tools button.on::after { content: ""; position: absolute; bottom: 2px; left: 14px; right: 14px; height: 2px; border-radius: 2px; background: #33d1c2; }
.tools button:active { background: rgba(255,255,255,.12); }
.tools .sep { width: 1px; margin: 8px 3px; background: rgba(255,255,255,.14); flex: none; }
.sheet {
  position: absolute; z-index: 6; left: 50%; transform: translateX(-50%);
  top: calc(max(8px, env(safe-area-inset-top)) + var(--tools-h, 48px) + 6px);
  width: min(380px, calc(100% - 16px)); max-height: 60vh; overflow: auto;
  background: rgba(28, 27, 44, .96); color: #f2f1fb; border-radius: 16px; padding: 12px;
  box-shadow: 0 12px 36px rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.08);
}
.sheet h3 { margin: 2px 4px 10px; font-size: 13px; color: #a3a1bd; font-weight: 600; letter-spacing: .02em; }
.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.keys button, .mods button { border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.06); color: inherit; border-radius: 10px; padding: 9px 6px; font-size: 13.5px; }
.keys button small { display: block; color: #a3a1bd; font-size: 11px; }
.mods { display: flex; gap: 6px; margin-bottom: 12px; }
.mods button { flex: 1; font-size: 17px; }
.mods button.on { background: #4744b0; border-color: #6d6ae0; }
.sheet textarea { width: 100%; min-height: 96px; border-radius: 10px; border: 1px solid rgba(255,255,255,.14); background: rgba(0,0,0,.25); color: inherit; padding: 10px; resize: vertical; }
.sheet .row { display: flex; gap: 8px; margin-top: 8px; }
.sheet .row button { flex: 1; border: 0; border-radius: 10px; padding: 10px; background: rgba(255,255,255,.1); color: inherit; }
.sheet .row button.go { background: #a4a1ff; color: #17153d; font-weight: 650; }
.status {
  position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; padding: 24px;
  background: rgba(10, 10, 20, .72); color: #f2f1fb; text-align: center;
}
.status .card { max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.status h2 { margin: 0; font-size: 19px; }
.status p { margin: 0; color: #c9c7df; font-size: 14px; }
.status .row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }
.status p.small { font-size: 13px; color: #a9a7c4; }
.status button { min-height: 44px; border: 0; border-radius: 12px; padding: 11px 18px; background: rgba(255,255,255,.12); color: inherit; }
.status button.go { background: #a4a1ff; color: #17153d; font-weight: 650; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(164,161,255,.25); border-top-color: #a4a1ff; animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
#kbd { position: absolute; left: -1000px; top: 0; width: 10px; height: 10px; opacity: 0; }
.toast {
  position: fixed; z-index: 10; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(28, 27, 44, .95); color: #f2f1fb; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  box-shadow: 0 6px 22px rgba(0,0,0,.4); max-width: calc(100% - 32px);
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.monitor-layout { display:flex; gap:8px; flex-wrap:wrap; margin:12px 0; }
.monitor-layout button { min-width:110px; border:1px solid #7777; border-radius:8px; padding:14px; }
.monitor-layout button.on { border:2px solid #8f8aff; }
.monitor-layout small { display:block; margin-top:5px; opacity:.7; }
.monitor-options { display:flex; flex-direction:column; gap:12px; }
.monitor-options label { display:flex; gap:8px; align-items:center; }
.monitor-options select { max-width:240px; }
body.mirror #screen { display:flex; align-items:center; justify-content:center; overflow:auto; }
.monitor-canvas { flex:none; outline:none; touch-action:none; }
body.mirror #tools button { width:auto; padding:8px 12px; }
.monitor-layout { position:relative; width:min(420px,100%); display:block; }
.monitor-layout button { position:absolute; min-width:0; min-height:0; margin:0; padding:7px; box-sizing:border-box; overflow:hidden; }
.tools { width:max-content; }
/* Phones: the toolbar wraps onto a second row instead of hiding buttons past the edge. */
@media (max-width: 560px) {
  body:not(.app) .tools { flex-wrap: wrap; justify-content: center; overflow: visible; }
  body:not(.app) .tools .sep { display: none; }
}
#screen { touch-action: none; }
