:root {
  --paper: #f7f5ef;
  --surface: #fffdf8;
  --ink: #1b1a17;
  --ink-2: #56544e;
  --mute: #8a877c;
  --faint: #b3ae9c;
  --line: #e6e3d6;
  --line-2: #d8d5cb;
  --hairline: #efecdf;
  --tile: #f0eee3;
  --hover: #f1efe6;
  --green: #178f5f;
  --danger: #cf3f45;
  --shadow-1: 0 1px 2px rgba(27, 26, 23, 0.04);
  --shadow-2: 0 10px 28px rgba(27, 26, 23, 0.09);
  --col: 920px;
  --pad: 24px;
  --sans: "Noto Sans SC", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --serif: "Newsreader", "Noto Serif SC", ui-serif, Georgia, serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 14.5px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.hidden { display: none !important; }
::selection { background: rgba(23, 143, 95, 0.16); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.display {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.005em;
}

/* Marks */
.mark { width: 24px; height: 24px; display: block; flex: 0 0 auto; }
.mark path { fill: currentColor; }
.bloom { width: 20px; height: 20px; display: block; flex: 0 0 auto; }
.bloom path { fill: currentColor; }
.ico { width: 14px; height: 14px; display: block; flex: 0 0 auto; }

@keyframes breathe {
  0%, 100% { opacity: 0.35; transform: scale(0.94); }
  50% { opacity: 1; transform: scale(1); }
}
.boot {
  min-height: 100%;
  display: grid;
  place-items: center;
  color: var(--ink);
}
.boot .mark, .frame-wait .mark {
  width: 32px;
  height: 32px;
  animation: breathe 1.6s ease-in-out infinite;
}

/* Buttons — one pill language */
.btn {
  appearance: none;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  height: 38px;
  padding: 0 18px;
  font-size: 13.5px;
  font-weight: 550;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease;
}
.btn:hover { background: #35332e; border-color: #35332e; }
.btn.lg { height: 46px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: #c8c4b4;
}
.btn.ghost:hover { background: var(--tile); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn .ico { color: currentColor; }
.text-btn {
  appearance: none;
  border: 0;
  background: none;
  color: var(--mute);
  padding: 4px 2px;
  font-size: 13px;
  border-radius: 6px;
}
.text-btn:hover { color: var(--ink); }
.text-btn.danger:hover { color: var(--danger); }

/* Action links (icon + word, green) */
.acts {
  border-top: 1px solid var(--hairline);
  margin-top: auto;
  padding-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
}
.act {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 550;
  color: var(--green);
}
.act:hover { color: #0f6b46; }
.act.danger { color: var(--danger); }
.act.danger:hover { color: #a92f34; }
.act:disabled { opacity: 0.5; cursor: default; }

/* Fields */
.field { display: block; margin: 0 0 14px; }
.field span {
  display: block;
  font-size: 13px;
  font-weight: 550;
  margin: 0 0 6px;
  color: var(--ink-2);
}
.inwrap { position: relative; }
.inwrap .ico {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: var(--mute);
  pointer-events: none;
}
.field input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 0 13px;
  outline: none;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.inwrap input { padding-left: 38px; }
.field input:hover { border-color: #c8c4b4; }
.field input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(27, 26, 23, 0.08);
}
.err { color: var(--danger); font-size: 13px; margin: 0 0 12px; }
.err:empty { display: none; }
.hint { color: var(--mute); margin: 0; font-size: 13.5px; line-height: 1.6; }

/* Login */
.auth {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 48px var(--pad);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  font-size: 15px;
  letter-spacing: 0.01em;
}
.auth-brand .mark { width: 20px; height: 20px; }
.auth-card {
  width: min(384px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow-1);
}
.auth-card h1 {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 6px;
}
.auth-card > .hint { margin-bottom: 22px; }
.auth-card .btn { margin-top: 8px; }
.auth-foot { color: var(--mute); font-size: 13px; margin: 0; }

/* App frame */
.app { min-height: 100%; display: flex; flex-direction: column; }
.top {
  width: min(var(--col), 100%);
  margin: 0 auto;
  padding: 26px var(--pad) 0;
  display: flex;
  align-items: center;
  gap: 22px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  font-weight: 650;
  font-size: 14.5px;
  letter-spacing: 0.01em;
  margin-right: auto;
}
.brand .mark { width: 19px; height: 19px; }
.top-link {
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--mute);
  padding-bottom: 2px;
  border-bottom: 1.5px solid transparent;
}
.top-link:hover { color: var(--ink); }
.top-link.on {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--ink);
}
.top-sep { width: 1px; height: 16px; background: var(--line-2); }
.top-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--mute);
}
.top-user .av { width: 26px; height: 26px; font-size: 11px; }

.page {
  width: min(var(--col), 100%);
  margin: 0 auto;
  padding: 0 var(--pad) 80px;
  flex: 1;
}
.page-head { margin: 56px 0 40px; }
.page-head h1 {
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.005em;
  margin: 0;
}
.page-head .hint { margin-top: 10px; }
.narrow { max-width: 720px; }

/* Section heads (管理) */
.sec-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 40px;
  border-bottom: 1px solid var(--line-2);
  padding-bottom: 12px;
}
.sec-head:first-of-type { margin-top: 0; }
.sec-head .ico, .sec-head .bloom { width: 17px; height: 17px; color: var(--ink); }
.sec-head b {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.005em;
  margin-right: auto;
}
.sec-add {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--green);
}
.sec-add:hover { color: #0f6b46; }

/* Cards */
.cardgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.cardgrid.home { margin-top: 0; }
.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-1);
  text-align: left;
}
.card.click { cursor: pointer; transition: box-shadow 0.16s ease, transform 0.16s ease, border-color 0.16s ease; }
.card.click:hover {
  border-color: var(--line-2);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}
.card.add {
  border-style: dashed;
  border-color: #c8c4b4;
  background: transparent;
  box-shadow: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--mute);
  min-height: 208px;
  cursor: pointer;
}
.card.add:hover { border-color: var(--ink); color: var(--ink-2); }
.add-ring {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px dashed #c8c4b4;
  border-radius: 999px;
}
.add-ring .ico { width: 17px; height: 17px; }
.card.add b { font-size: 13.5px; font-weight: 550; color: var(--ink-2); }
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.card-head.row { align-items: center; }
.tile {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--tile);
  color: var(--ink);
}
.tile .bloom { width: 20px; height: 20px; }
.tile.sm { width: 40px; height: 40px; border-radius: 12px; }
.tile.sm .bloom { width: 18px; height: 18px; }
.card-name {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.005em;
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.card-head .card-name { margin: 0; margin-right: auto; }
.card-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Status (small-caps + dot) */
.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--mute);
  white-space: nowrap;
}
.status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #cfccbe;
  flex: 0 0 auto;
}
.status.live { color: var(--green); }
.status.live i { background: var(--green); animation: breathe 1.6s ease-in-out infinite; }
.status.ink { color: var(--ink); }
.status.ink i { background: var(--ink); }
.status.off { color: var(--danger); }
.status.off i { background: var(--danger); }

/* Occupancy row */
.occ {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  min-height: 26px;
  font-size: 12.5px;
  color: var(--mute);
}
.occ.empty { color: var(--faint); }
.seats { display: inline-flex; align-items: center; gap: 5px; }
.seats .ico { width: 14px; height: 14px; }
.card .btn { margin-top: 18px; }

.stack { display: flex; flex: 0 0 auto; }
.av {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 11px;
  color: #fff;
  background: hsl(var(--h, 150) 30% 46%);
  flex: 0 0 auto;
}
.av.big { width: 40px; height: 40px; font-size: 14px; }
.av.mini {
  width: 24px;
  height: 24px;
  font-size: 10px;
  border: 2px solid var(--surface);
}
.stack .av.mini + .av.mini { margin-left: -7px; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; min-height: 27px; }
.member-activity { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; color: var(--mute); font-size: 12px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}
.chip .bloom { width: 12px; height: 12px; }
.chip.live {
  color: var(--green);
  border-color: rgba(23, 143, 95, 0.28);
  background: rgba(23, 143, 95, 0.07);
}
.chip.none { border-style: dashed; color: var(--faint); }
button.chip { appearance: none; cursor: pointer; font-family: var(--mono); font-size: 12px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
button.chip:hover { border-color: var(--ink); color: var(--ink); background: var(--tile); }

/* Panels (settings) */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-1);
  margin-bottom: 14px;
}
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
}
label.switch-row { cursor: pointer; }
.switch-row b { display: block; font-size: 14.5px; font-weight: 600; }
.switch-row em {
  display: block;
  margin-top: 3px;
  font-style: normal;
  color: var(--mute);
  font-size: 13px;
  line-height: 1.5;
}
.switch-row input {
  appearance: none;
  width: 42px;
  height: 25px;
  flex: 0 0 auto;
  margin: 0;
  border-radius: 999px;
  background: var(--line-2);
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
}
.switch-row input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease;
}
.switch-row input:checked { background: var(--green); }
.switch-row input:checked::after { transform: translateX(17px); }
.switch-row input:disabled { opacity: 0.45; }
.cdp-empty {
  padding: 12px 20px 18px;
  color: var(--mute);
  font-size: 13px;
}
.cdp-empty a { color: var(--ink); font-weight: 550; }
.cdp-rows .switch-row { border-top: 1px solid var(--hairline); padding-top: 14px; padding-bottom: 14px; }

.panel-head {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 18px 20px;
}
.panel-head b { display: block; font-size: 14.5px; font-weight: 600; }
.panel-head em {
  display: block;
  margin-top: 3px;
  font-style: normal;
  color: var(--mute);
  font-size: 13px;
  line-height: 1.5;
}
.panel-head code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--tile);
  border-radius: 5px;
  padding: 1px 5px;
}
.proxy-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 20px 2px;
}
.proxies { padding-bottom: 6px; }
.proxy-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
}
.proxy-row + .proxy-row { border-top: 1px solid var(--hairline); }
.proxy-row.all {
  border-bottom: 1px solid var(--hairline);
  background: var(--tile);
}
.proxy-id { flex: 0 0 148px; min-width: 0; }
.proxy-id b {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proxy-input {
  flex: 1;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 0 12px;
  outline: none;
  background: #fff;
  font-family: var(--mono);
  font-size: 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.proxy-input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(27, 26, 23, 0.08);
}
.proxy-input::placeholder { font-family: var(--sans); color: var(--mute); }
.proxy-row .btn { height: 34px; padding: 0 14px; font-size: 13px; }

/* Modal */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(27, 26, 23, 0.42);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
  overflow-y: auto;
}
.sheet {
  width: min(400px, 100%);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: 16px;
  padding: 26px 24px 22px;
  box-shadow: 0 24px 64px rgba(27, 26, 23, 0.25);
}
.sheet h2 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
}
.sheet .hint { margin-bottom: 18px; font-size: 13.5px; }
.picks { display: flex; gap: 8px; flex-wrap: wrap; }
.pick {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.pick:has(input:checked) {
  border-color: var(--ink);
  background: var(--tile);
  color: var(--ink);
}
.pick input { accent-color: var(--ink); width: 14px; height: 14px; flex: 0 0 auto; margin: 0; }
.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* Desk stage */
.stage {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr);
}
.chrome {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  z-index: 3;
}
.back {
  appearance: none;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 550;
  width: max-content;
  padding: 6px 10px 6px 5px;
  border-radius: 999px;
}
.back:hover { background: var(--hover); color: var(--ink); }
.back svg { width: 17px; height: 17px; }
.chrome-mid { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chrome-mid .bloom { width: 15px; height: 15px; color: var(--ink); }
.title { font-weight: 600; font-size: 13.5px; letter-spacing: -0.01em; }
.who {
  color: var(--mute);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.who:not(:empty)::before { content: "·"; margin-right: 8px; }
.chrome-end {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.chrome-btn {
  appearance: none;
  border: 1px solid var(--line-2);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 550;
}
.chrome-btn svg { width: 14px; height: 14px; }
.chrome-btn:hover { background: var(--tile); }
.chrome-btn:disabled { opacity: 0.45; }
.clip-chip {
  appearance: none;
  display: none;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  height: 32px;
  max-width: 268px;
  padding: 0 6px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  letter-spacing: -0.01em;
  color: var(--mute);
  overflow: hidden;
  white-space: nowrap;
  transition: background 0.12s ease;
}
.clip-chip.show { display: inline-flex; }
.clip-chip:hover { background: var(--tile); }
.clip-chip.busy { color: var(--ink); }
.clip-chip > span:not(.clip-keys):not(.clip-sep) {
  min-width: 0;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
.clip-chip .ico-clip { width: 15px; height: 15px; flex: 0 0 auto; color: var(--ink-2); }
.clip-sep {
  width: 1px;
  height: 14px;
  background: var(--line);
  flex: 0 0 auto;
}
.clip-keys {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  padding-right: 4px;
}
.clip-keys kbd {
  font: inherit;
  font-size: 11px;
  font-weight: 550;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-2);
  border-radius: 5px;
  padding: 1px 6px;
}
.clip-chip .pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex: 0 0 auto;
  animation: breathe 1.15s ease-in-out infinite;
}
.clip-chip .ico-img,
.toast .ico-img {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--ink);
}
.toast .ico-img { width: 18px; height: 18px; color: #fff; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(10px);
  opacity: 0;
  pointer-events: none;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13.5px;
  box-shadow: 0 12px 32px rgba(27, 26, 23, 0.28);
  transition: opacity 0.18s ease, transform 0.18s ease;
  max-width: min(420px, calc(100vw - 32px));
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 6px;
}
.toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-drop-shield {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
}
.file-drop-shield.on { display: block; }
.frame { position: relative; min-height: 0; overflow: hidden; background: #fff; }
.frame iframe, .frame .seat-cast { width: 100%; height: 100%; border: 0; display: block; }
.seat-cast { background: #fff; outline: none; cursor: default; touch-action: none; object-fit: contain; object-position: center; }
.seat-keyboard { position: fixed; width: 1px; height: 1px; left: -10px; bottom: 0; opacity: 0; pointer-events: none; }
.frame-wait {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #fff;
  z-index: 2;
  color: var(--ink);
}
.frame-wait.gone { display: none; }

@media (max-width: 560px) {
  :root { --pad: 20px; }
  .top { padding-top: 18px; gap: 16px; }
  .top-user span { display: none; }
  .page-head { margin: 36px 0 28px; }
  .page-head h1 { font-size: 30px; }
  .cardgrid { grid-template-columns: 1fr; }
  .chrome { grid-template-columns: auto 1fr auto; }
  .chrome-mid { justify-self: start; }
  .who { display: none; }
  .clip-sep, .clip-keys { display: none; }
  .clip-chip { padding-right: 12px; }
}
