/* D2Coding (OFL, vendor/fonts/D2Coding-OFL.txt) — 한글이 정확히 두 칸 폭이라 터미널에서 띄어 보이지 않는다 */
@font-face { font-family: "D2Coding"; font-weight: 400; font-display: block; src: url("/vendor/fonts/d2coding-full.woff2") format("woff2"); }
@font-face { font-family: "D2Coding"; font-weight: 700; font-display: block; src: url("/vendor/fonts/d2coding-bold-full.woff2") format("woff2"); }

:root {
  --bg: #0b0f17; --panel: #111827; --panel-2: #172033; --line: #233047;
  --text: #e6edf6; --dim: #8a99b0; --accent: #5aa9ff; --accent-2: #2f7de0;
  --ok: #3fcf8e; --warn: #f2c14e; --bad: #ff6b6b;
  --side: 300px; --bar: 52px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text);
  word-break: keep-all; overflow-wrap: anywhere;
  font: 14px/1.45 var(--ui-font, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", system-ui, sans-serif); }
button, input, select { font: inherit; color: inherit; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .92em; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.dim { color: var(--dim); }
[hidden] { display: none !important; }

#app { display: grid; height: 100dvh; grid-template: var(--bar) 1fr / var(--side) 1fr;
  grid-template-areas: "bar bar" "side main"; padding-bottom: env(safe-area-inset-bottom); }

.bar { grid-area: bar; display: flex; align-items: center; gap: 12px; padding: 0 14px;
  padding-top: env(safe-area-inset-top); border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .02em; font-size: 16px; }
.brand img { width: 24px; height: 24px; }
.brand small { font-weight: 400; color: var(--dim); font-size: 12px; }
.bar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.btn { border: 1px solid var(--line); background: var(--panel-2); padding: 6px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.primary:hover { background: var(--accent); }
.icon-btn { border: 0; background: transparent; font-size: 18px; width: 36px; height: 36px; border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: var(--panel-2); }

.side { grid-area: side; overflow: auto; border-right: 1px solid var(--line); background: var(--panel); }
.side-head { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px 6px; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.side-foot { padding: 12px 14px; }
.host { padding: 6px 0 10px; border-bottom: 1px solid var(--line); }
.host-h { display: flex; align-items: center; gap: 8px; padding: 6px 14px; font-weight: 600; }
.host-h .tag { font-weight: 400; font-size: 11px; color: var(--dim); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.host-h .meta { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--dim); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(63, 207, 142, .15); }
.host-off { padding: 2px 14px 4px 30px; font-size: 12px; color: var(--dim); }
.sess { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; padding: 7px 14px 7px 30px; cursor: pointer; border-left: 3px solid transparent; }
.sess:hover { background: var(--panel-2); }
.sess.open { border-left-color: var(--accent); background: var(--panel-2); }
.sess .n { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess .p { grid-column: 1 / -1; font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 10px; align-self: center; }
.badge.att { color: var(--ok); background: rgba(63, 207, 142, .12); }
.badge.idle { color: var(--dim); background: var(--panel-2); }
.badge.shell { color: var(--warn); background: rgba(242, 193, 78, .12); }

.main { grid-area: main; position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabbar { display: flex; align-items: stretch; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 38px; }
.tabbar .icon-btn { height: auto; border-radius: 0; flex: none; }
.tabs { display: flex; flex: 1; overflow-x: auto; scrollbar-width: none; }
.newver { position: fixed; z-index: 40; left: 50%; top: 8px; transform: translateX(-50%); display: flex; gap: 10px; align-items: center;
  padding: 8px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--accent); box-shadow: 0 6px 24px rgba(0, 0, 0, .35); white-space: nowrap; }
@media (max-width: 760px) { .newver .dim { display: none; } }
.toast { position: absolute; z-index: 30; right: 16px; bottom: 16px; max-width: min(520px, calc(100% - 32px)); padding: 10px 14px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-size: 13px; box-shadow: 0 6px 24px rgba(0, 0, 0, .35); word-break: break-all; }
.toast.err { border-color: var(--bad); }
.stage.drop { outline: 2px dashed var(--accent); outline-offset: -6px; }
.tab { display: flex; align-items: center; gap: 8px; padding: 0 8px 0 14px; border-right: 1px solid var(--line); cursor: pointer; white-space: nowrap; color: var(--dim); font-size: 13px; }
.tab.on { color: var(--text); background: var(--bg); box-shadow: inset 0 2px 0 var(--accent); }
.tab .x { border: 0; background: transparent; color: var(--dim); cursor: pointer; border-radius: 4px; width: 22px; height: 22px; }
.tab .x:hover { background: var(--panel-2); color: var(--text); }
.tab.dead { text-decoration: line-through; }
.stage { position: relative; flex: 1; min-height: 0; }
.term { position: absolute; inset: 0; padding: 6px 4px 4px 8px; background: var(--bg); }
.term .xterm { height: 100%; }
.notice { position: absolute; left: 12px; right: 12px; top: 10px; z-index: 5; display: flex; gap: 10px; align-items: flex-start;
  background: #2a2412; border: 1px solid #6b5520; color: #ffe7a6; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.notice button { margin-left: auto; }
.gone { position: absolute; inset: auto 12px 12px 12px; z-index: 5; display: flex; gap: 10px; align-items: center;
  background: var(--panel-2); border: 1px solid var(--line); padding: 10px 12px; border-radius: 8px; }
.empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 4px; }
.empty img { width: 72px; opacity: .9; }
.empty h1 { margin: 8px 0 0; font-size: 22px; }
.empty p { max-width: 440px; margin: 4px 0; }

.keys { display: flex; gap: 6px; padding: 6px 8px; overflow-x: auto; background: var(--panel); border-top: 1px solid var(--line); }
.keys button { flex: none; min-width: 44px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }

dialog { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.dlg { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.dlg.wide { width: min(980px, calc(100vw - 24px)); }
dialog:has(.wide) { width: auto; max-width: calc(100vw - 24px); }
.dlg h2 { margin: 0; font-size: 17px; }
.dlg label, .field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--dim); }
.dlg input, .dlg select { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--text); width: 100%; }
.dlg input:focus, .dlg select:focus { outline: 2px solid var(--accent-2); border-color: transparent; }
.name-row { display: flex; align-items: center; gap: 6px; }
.crumb { font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--text); font-size: 12px; word-break: break-all; }
.dirs { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.dirs li { padding: 7px 10px; cursor: pointer; color: var(--text); font-size: 13px; border-bottom: 1px solid #141c2b; }
.dirs li:hover, .dirs li.sel { background: var(--panel-2); }
.dirs li.up { color: var(--dim); }
.err { color: var(--bad); margin: 0; min-height: 1em; font-size: 13px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.grow { flex: 1; }
.hosts-wrap { overflow-x: auto; }
.hosts { border-collapse: collapse; width: 100%; font-size: 13px; }
.hosts th { text-align: left; color: var(--dim); font-weight: 500; padding: 4px 6px; white-space: nowrap; }
.hosts td { padding: 3px 4px; vertical-align: middle; }
.hosts td input { padding: 6px 8px; min-width: 90px; }
.hosts td.ops { white-space: nowrap; }
.hosts td.ops button { border: 0; background: transparent; cursor: pointer; color: var(--dim); width: 28px; height: 28px; border-radius: 6px; }
.hosts td.ops button:hover { background: var(--panel-2); color: var(--text); }

#app.side-hidden { grid-template-columns: 0 1fr; }
#app.side-hidden .side { visibility: hidden; border: 0; }
.size-row { display: flex; gap: 8px; align-items: center; }
.size-row input[type=range] { flex: 1; padding: 0; accent-color: var(--accent); }
.dlg label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.dlg label.check input { width: auto; accent-color: var(--accent); }

.only-narrow { display: none; }
@media (max-width: 760px) {
  #app { grid-template: var(--bar) 1fr / 1fr; grid-template-areas: "bar" "main"; }
  .only-narrow { display: inline-flex; align-items: center; justify-content: center; }
  #app.side-hidden .side { visibility: visible; }
  .side { position: fixed; z-index: 20; top: var(--bar); bottom: 0; left: 0; width: min(86vw, 340px); transform: translateX(-100%); transition: transform .18s ease; }
  .side.open { transform: none; }
  .scrim { position: fixed; inset: var(--bar) 0 0 0; background: rgba(0, 0, 0, .45); z-index: 15; display: none; }
  .scrim.open { display: block; }
  .brand small, #btn-hosts { display: none; }
  .bar { gap: 6px; padding: 0 8px; }
}

.gate { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(ellipse at top, var(--panel-2) 0%, var(--bg) 60%); }
.gate-card { width: min(380px, 100%); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 32px 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
.gate-card img { width: 72px; }
.gate-card h1 { margin: 0; font-size: 24px; letter-spacing: .02em; }
.gate-card p { margin: 0; color: var(--dim); }
.btn.big { padding: 10px 22px; font-size: 15px; border-radius: 10px; margin-top: 6px; }
