:root {
  --paper: #f7f6f3;
  --card: #ffffff;
  --ink: #14312c;
  --ink-soft: #5a6f6a;
  --line: #2f6b5e;
  --line-dim: #c9d6d2;
  --brass: #a8682c;
  --alert: #8c2f2f;
  --off: #a9aaa4;
  --rule: #dfdbd2;
  --fs-display: clamp(1.75rem, 6vw, 2.375rem);
  --fs-body: 1rem;
  --fs-small: 0.8125rem;
  --sans: system-ui, -apple-system, "Segoe UI", "PingFang TC",
          "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --gutter: 34px;
  --tap: 48px;
  --z-overlay: 50;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: max(18px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.wrap {
  max-width: 440px;
  margin: 0 auto;
}

.eyebrow {
  font-family: var(--mono);
  font-size: var(--fs-small);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow .brand {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  flex: none;
}

h1 {
  font-size: var(--fs-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 12px;
}

.lede {
  color: var(--ink-soft);
  margin: 0 0 26px;
  max-width: 34ch;
}

.hint {
  display: block;
  font-weight: 400;
  color: var(--ink-soft);
  margin-top: 2px;
}

.foot {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-size: var(--fs-small);
  color: var(--ink-soft);
}
.foot a {
  color: var(--line);
  font-weight: 600;
  cursor: pointer;
}

label {
  display: block;
  font-size: var(--fs-small);
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0 0 6px;
}

input {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--rule);
  border-radius: 10px;
  transition: border-color 0.18s;
}
input.mono {
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.02em;
}
input:hover {
  border-color: #c4bfb4;
}
input:focus {
  outline: none;
  border-color: var(--line);
  box-shadow: 0 0 0 3px rgba(47, 107, 94, 0.16);
}
input[readonly] {
  background: #f0efeb;
  color: var(--ink-soft);
}

.go, .act button {
  width: 100%;
  min-height: var(--tap);
  border: none;
  border-radius: 10px;
  background: var(--line);
  color: #fff;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.go:hover:not(:disabled), .act button:hover:not(:disabled) {
  background: #255a4e;
}
.go:active:not(:disabled), .act button:active:not(:disabled) {
  transform: translateY(1px);
}
.go:disabled, .act button:disabled {
  background: #b6c4c0;
  cursor: not-allowed;
}
.go:focus-visible, .act button:focus-visible {
  outline: 3px solid var(--brass);
  outline-offset: 2px;
}

.msg {
  font-size: var(--fs-small);
  font-weight: 500;
  margin: 0 0 14px;
  min-height: 1.2em;
}
.msg.bad {
  color: var(--alert);
}
.msg.good {
  color: var(--line);
}

.err {
  display: none;
  color: var(--alert);
  font-size: var(--fs-small);
  margin-top: 6px;
  font-weight: 500;
}
.err.show {
  display: block;
  margin-top: 14px;
}

.gate {
  max-width: 400px;
  margin: 0 auto;
}
.gate input {
  margin-bottom: 16px;
}
.gate .foot {
  margin-top: 18px;
}

.cord {
  position: relative;
  padding-left: var(--gutter);
}
.cord::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 8px;
  bottom: 64px;
  width: 2px;
  background: var(--line-dim);
  border-radius: 1px;
}
.cord::after {
  content: "";
  position: absolute;
  left: 11px;
  top: 8px;
  width: 2px;
  height: var(--cord-fill, 0px);
  background: var(--line);
  border-radius: 1px;
  transition: height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.field {
  position: relative;
  margin-bottom: 22px;
}
.field .node {
  position: absolute;
  left: calc(-1 * var(--gutter) + 6px);
  top: 30px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--line-dim);
  transition: border-color 0.25s, background 0.25s;
}
.field.on .node {
  border-color: var(--line);
  background: var(--line);
}
.field.bad input {
  border-color: var(--alert);
}
.field.bad .err {
  display: block;
}

.act {
  position: relative;
  margin-top: 28px;
}
.act button.ready {
  background: var(--brass);
}
.act button.ready:hover {
  background: #8e5623;
}

.seal {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  margin-bottom: 22px;
  animation: rise 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.seal-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--brass);
  flex: none;
}

.seal-txt {
  font-weight: 650;
}

dl {
  margin: 0 0 22px;
  padding: 0;
  font-size: var(--fs-small);
}

dt {
  color: var(--ink-soft);
  float: left;
  width: 82px;
  clear: left;
  padding: 5px 0;
}

dd {
  margin: 0 0 0 82px;
  padding: 5px 0;
  font-family: var(--mono);
  word-break: break-all;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.head h1 {
  font-size: 1.75rem;
  margin: 0;
}
.head .add {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid var(--rule);
  background: var(--card);
  color: var(--line);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.18s;
}
.head .add:first-of-type {
  margin-left: auto;
}
.head .add:hover {
  border-color: var(--line);
  background: #eef3f1;
}

.bus {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--line);
  margin: 0 0 22px;
  padding-left: 2px;
}
.bus .lamp {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  flex: none;
  animation: pulse 2.4s ease-in-out infinite;
}
.bus.down {
  color: var(--alert);
}
.bus.down .lamp {
  background: var(--alert);
  animation: none;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}
.sec {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 22px 0 9px;
  padding-left: 2px;
}
.sec:first-of-type {
  margin-top: 0;
}

.swipe {
  position: relative;
  overflow: hidden;
  border-radius: 0 12px 12px 0;
  margin-bottom: 9px;
}

.del {
  position: absolute;
  inset: 0 0 0 auto;
  width: 88px;
  background: var(--alert);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--sans);
  font-size: 0.75rem;
  gap: 2px;
  border: none;
  cursor: pointer;
}
.del .ic {
  font-size: 1.125rem;
}

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--off);
  border-radius: 0 12px 12px 0;
  padding: 13px 14px;
  min-height: 72px;
  touch-action: pan-y;
  user-select: none;
}
.row.on {
  border-left-color: var(--line);
}
.row.wait {
  border-left-color: var(--brass);
}
.row.sent {
  opacity: 0.66;
  cursor: pointer;
}

.av {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex: none;
  background: #eef3f1;
  color: var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9375rem;
}
.av.p {
  background: var(--line);
  color: #fff;
}

.dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2.5px solid var(--card);
  background: var(--off);
}
.dot.on {
  background: var(--line);
}

.info {
  flex: 1;
  min-width: 0;
}
.info .nm {
  font-weight: 650;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.info .st {
  font-size: var(--fs-small);
  color: var(--ink-soft);
}
.info .st.wait {
  color: var(--brass);
}

.call {
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  flex: none;
  border: none;
  background: var(--line);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.call:hover:not(:disabled) {
  background: #255a4e;
}
.call:active {
  transform: scale(0.94);
}
.call:disabled {
  background: var(--line-dim);
  cursor: not-allowed;
}

.acts {
  display: flex;
  gap: 7px;
  flex: none;
}
.acts button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1.125rem;
  transition: background 0.18s;
}
.acts .ok {
  background: var(--line);
  color: #fff;
}
.acts .ok:hover {
  background: #255a4e;
}
.acts .no {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--rule) !important;
}
.acts .no:hover {
  background: #f0efeb;
  color: var(--ink);
}

.resend {
  color: var(--brass);
  font-size: 1.125rem;
}

.empty {
  border: 1.5px dashed var(--line-dim);
  border-radius: 12px;
  padding: 30px 20px;
  text-align: center;
  color: var(--ink-soft);
}
.empty strong {
  display: block;
  color: var(--ink);
  font-size: 1.0625rem;
  margin-bottom: 6px;
}

.back {
  background: transparent;
  border: none;
  color: var(--line);
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-bottom: 18px;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(34px, env(safe-area-inset-bottom));
}

.v-rmt {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--ink);
}
.v-rmt.hide {
  display: none;
}

.v-lcl {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  right: 16px;
  width: 108px;
  height: 148px;
  object-fit: cover;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: #000;
  z-index: 2;
}
.v-lcl.hide {
  display: none;
}

.peer {
  position: relative;
  z-index: 2;
  text-align: center;
  color: #fff;
  margin-bottom: 56px;
}

.peer-av {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  margin: 0 auto 20px;
  background: var(--line);
  border: 3px solid var(--brass);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 700;
}

.peer-nm {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.peer-st {
  font-family: var(--mono);
  font-size: var(--fs-small);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-top: 8px;
}

.peer-bar {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  left: 16px;
  z-index: 3;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 650;
  background: rgba(20, 49, 44, 0.55);
  padding: 7px 12px;
  border-radius: 999px;
}

.ctrls {
  position: relative;
  z-index: 3;
  margin-top: auto;
  display: flex;
  gap: 18px;
  align-items: center;
}

.rnd {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 650;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  transition: background 0.2s, transform 0.1s;
}
.rnd .ic {
  display: block;
  font-size: 1.625rem;
  line-height: 1;
  margin-bottom: 3px;
}
.rnd:hover {
  background: rgba(255, 255, 255, 0.26);
}
.rnd:active {
  transform: scale(0.95);
}
.rnd.on {
  background: #fff;
  color: var(--ink);
}
.rnd.ok {
  background: var(--line);
}
.rnd.ok:hover {
  background: #2f7d6c;
}
.rnd.hang {
  background: var(--alert);
}
.rnd.hang:hover {
  background: #a33a3a;
}
.rnd:focus-visible {
  outline: 3px solid var(--brass);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
@media (min-width: 640px) {
  body {
    padding-top: 48px;
  }
  :root {
    --gutter: 40px;
  }
}
