:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-muted: #f0ede6;
  --border: #dcd7cc;
  --text: #1c1b18;
  --text-muted: #6e6a61;
  --accent: #d94426;
  --accent-soft: rgba(217, 68, 38, 0.12);
  --ok: #268a52;
  --warn: #c77b16;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100%;
  min-height: 100%;
}

.hidden {
  display: none !important;
}

.view {
  width: 100%;
  min-height: 100dvh;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ---------- Shared Buttons ---------- */
button,
.file-pick-label {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

.primary-btn {
  background: var(--text);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 15px;
}

.primary-btn:active {
  opacity: 0.85;
}

.secondary-btn {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
}

.ghost-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  color: var(--text-muted);
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
}

.pill-btn.accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.text-btn {
  font-size: 13px;
  color: var(--text-muted);
  padding: 4px 8px;
}

.full-width {
  width: 100%;
}

.flex-1 {
  flex: 1;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- PC View ---------- */
.pc-container {
  max-width: 780px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.pc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hero-card,
.steps-card {
  padding: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.hero-card h1 {
  margin: 0 0 10px;
  font-size: 26px;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.lead {
  margin: 0 0 18px;
  color: var(--text-muted);
  line-height: 1.65;
  font-size: 15px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.os-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 640px) {
  .os-grid {
    grid-template-columns: 1fr;
  }
}

.os-card {
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.os-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.os-title {
  font-weight: 700;
  font-size: 15px;
}

.os-desc {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.os-badge {
  align-self: flex-start;
  margin-top: 4px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
}

.steps-card h2 {
  margin: 0 0 14px;
  font-size: 16px;
}

.step-list {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step-list li {
  line-height: 1.55;
  font-size: 14px;
}

.step-list strong {
  display: block;
}

.step-list span {
  color: var(--text-muted);
  font-size: 13px;
}

.relay-url-box {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.relay-label {
  font-size: 12px;
  color: var(--text-muted);
}

.relay-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.relay-row code {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
  overflow-x: auto;
}

/* ---------- Mobile Connect View ---------- */
.connect-container {
  max-width: 460px;
  margin: 0 auto;
  padding: calc(16px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.compact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.connect-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.connect-card h1 {
  margin: 0;
  font-size: 20px;
}

.scanner-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: #111;
}

.scanner-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-frame {
  position: absolute;
  inset: 18%;
  border: 2px solid var(--accent);
  border-radius: 12px;
  pointer-events: none;
}

.scanner-close {
  position: absolute;
  bottom: 10px;
  right: 10px;
}

.status-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.error-banner {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
}

/* ---------- Mobile Controller View ---------- */
#view-controller {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(8px + var(--safe-top)) 10px calc(8px + var(--safe-bottom));
  gap: 8px;
  overflow: hidden;
  touch-action: manipulation;
}

.ctrl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
  flex-shrink: 0;
}

.ctrl-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}

.status-dot.live {
  background: var(--ok);
}

.status-dot.connecting {
  background: var(--warn);
}

.status-dot.error {
  background: var(--accent);
}

.ctrl-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ctrl-pc-name {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ctrl-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.ctrl-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.e2ee-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(38, 138, 82, 0.12);
  color: var(--ok);
}

.chip-btn {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.chip-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.input-card {
  padding: 10px 12px 6px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#text-input {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  min-height: 44px;
  max-height: 130px;
}

.input-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--surface-muted);
  padding-top: 4px;
}

.input-card-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.keybar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex-shrink: 0;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.keybar::-webkit-scrollbar {
  display: none;
}

.key-btn {
  flex-shrink: 0;
  padding: 7px 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  min-width: 40px;
  text-align: center;
}

.key-btn:active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.trackpad-wrap {
  flex: 1;
  min-height: 110px;
  display: flex;
}

.trackpad {
  flex: 1;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.trackpad.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.trackpad-hint {
  font-size: 12px;
  color: var(--text-muted);
  pointer-events: none;
  line-height: 1.5;
}

.drawer-panel {
  padding: 12px 14px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
}

.drawer-panel input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.share-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.share-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.select-input {
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 13px;
  color: var(--text);
}

.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}

#transfer-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s linear;
}

.clip-result {
  padding: 10px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
  max-height: 140px;
  overflow: auto;
  word-break: break-word;
}

.clip-result img {
  max-width: 100%;
  max-height: 100px;
  border-radius: 6px;
  display: block;
  margin-bottom: 6px;
}

.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
}

.mouse-btns {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: center;
}

.bar-btn {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  min-width: 44px;
}

.bar-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.bar-btn.accent-outline {
  border-color: var(--accent);
  color: var(--accent);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(64px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(28, 27, 24, 0.92);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 100;
  pointer-events: none;
}
