:root {
  color-scheme: light;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  color: #111111;
  background: #f2f2f0;
  --surface: #ffffff;
  --inset: #f9f9f7;
  --line: #dededb;
  --muted: #686866;
  --accent: #ff5a36;
  --accent-hover: #ff795c;
  --accent-ink: #a3331d;
  --accent-soft: #fff0eb;
  --button-background: #fff;
  --button-hover: #f2f2f0;
  --button-line: #c9c9c5;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  -webkit-text-size-adjust: 100%;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

button,
input,
textarea {
  font: inherit;
}

button,
input[type="range"],
.switch-row {
  -webkit-tap-highlight-color: transparent;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: .52;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding-block: 12px;
  padding-inline: max(24px, calc((100vw - 1220px) / 2));
  color: #ffffff;
  background: #090909;
  border-bottom: 1px solid #262626;
  --button-background: #181818;
  --button-hover: #292929;
  --button-line: #444444;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-name {
  font-size: 1.17rem;
  font-weight: 860;
  letter-spacing: -.05em;
  white-space: nowrap;
}

.brand-name > span {
  color: var(--accent);
}

.brand-product {
  padding-left: 11px;
  border-left: 1px solid #484848;
  color: #dededb;
  font-size: .85rem;
  font-weight: 650;
  white-space: nowrap;
}

.header-actions,
.editor-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.header-actions {
  justify-content: flex-end;
}

.header-action {
  flex: none;
}

.connection-dot,
.remote-status-dot {
  display: inline-block;
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #858580;
}

[data-connection="pending"] .connection-dot {
  background: var(--accent);
}

[data-connection="connected"] .connection-dot {
  background: #63c49e;
}

.workspace {
  width: min(100%, 1268px);
  padding: 38px 24px 46px;
  margin-inline: auto;
}

.subtle {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.55;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 330px);
  align-items: stretch;
  gap: 18px;
}

.display-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 12px;
}

.display-column > .button {
  min-height: 48px;
}

.display-column > .settings-panel {
  flex: 1;
}

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 34px rgb(0 0 0 / 4%);
}

.panel-header,
.editor-actions,
.editor-footer,
.settings-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.panel-header {
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.125rem;
  letter-spacing: -.025em;
}

#script {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  min-height: clamp(260px, 43vh, 515px);
  padding: 16px 18px;
  resize: vertical;
  color: inherit;
  caret-color: var(--accent);
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 1rem;
  line-height: 1.75;
}

#script::placeholder {
  color: #73736f;
}

.editor-footer {
  justify-content: space-between;
  min-height: 28px;
  margin-top: 10px;
}

.settings-fields {
  display: grid;
  gap: 8px;
}

.range-row {
  display: grid;
  align-items: center;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 12px;
}

.range-row label {
  font-size: .9rem;
  font-weight: 620;
}

.range-row label > span {
  min-width: 0;
}

.range-row output {
  color: var(--accent-ink);
  font-size: .84rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: end;
}

.range-row input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  height: 44px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.mirror-group {
  display: grid;
  gap: 4px;
  margin: 8px 0 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 620;
}

.switch-row > input[type="checkbox"] {
  position: absolute;
  width: 40px;
  height: 24px;
  margin: 0;
  opacity: 0;
  cursor: inherit;
}

.switch {
  display: grid;
  flex: none;
  align-items: center;
  width: 40px;
  height: 24px;
  padding-inline: 3px;
  pointer-events: none;
  background: #e4e4e1;
  border: 1px solid #969693;
  border-radius: 99px;
}

.switch::before {
  width: 16px;
  height: 16px;
  content: "";
  background: #ffffff;
  border-radius: 50%;
}

.switch-row > input:checked + .switch {
  background: var(--accent);
  border-color: var(--accent);
}

.switch-row > input:checked + .switch::before {
  justify-self: end;
  background: #181818;
}

.switch-row > input:focus-visible + .switch {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.settings-footer {
  margin-top: auto;
  padding-top: 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid var(--button-line);
  border-radius: 9px;
  color: inherit;
  background: var(--button-background);
  font-size: .9rem;
  font-weight: 650;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.button.primary {
  border-color: var(--accent);
  color: #111111;
  background: var(--accent);
}

.button.secondary {
  background: transparent;
}

.button.icon {
  flex: none;
  padding-inline: 10px;
}

@media (hover: hover) {
  .button:not(:disabled):hover {
    background: var(--button-hover);
  }

  .button.primary:not(:disabled):hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
  }
}

.prompter-screen {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: block;
  overflow: hidden;
  color: white;
  background: black;
  color-scheme: dark;
  --line: #393939;
  --muted: #b9b9b5;
  --button-background: #222222;
  --button-hover: #2c2c2c;
  --button-line: #4c4c4c;
}

.prompter-screen:fullscreen {
  display: block;
}

.prompt-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: black;
  touch-action: none;
  user-select: none;
}

.prompt-mirror {
  position: absolute;
  inset: 0;
  transform-origin: center;
}

.prompt-text {
  position: absolute;
  inset-inline: 0;
  top: 0;
  margin: 0;
  font-weight: 650;
  white-space: pre-wrap;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.prompt-text p {
  margin: 0 0 .6em;
}

.prompt-controls {
  position: absolute;
  inset-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right));
  top: max(12px, env(safe-area-inset-top));
  z-index: 1;
  max-height: calc(100% - 24px);
  max-width: 960px;
  padding: 12px;
  margin-inline: auto;
  overflow: auto;
  overscroll-behavior: contain;
  background: #181818;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.prompt-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.prompt-adjustments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 10px;
}

.prompt-adjustment-group {
  display: grid;
  grid-template-columns: auto minmax(64px, auto) auto;
  align-items: center;
  column-gap: 6px;
}

.prompt-adjustment-value {
  text-align: center;
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.prompt-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: .85rem;
}

.prompt-status:empty {
  display: none;
}

.prompt-wake {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 8px;
}

.prompt-wake .prompt-status {
  margin: 0;
}

#wake-lock-status[data-state="active"] {
  color: #8bdca1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 740px) {
  .app-header {
    min-height: 64px;
    padding-inline: 16px;
  }

  .workspace {
    padding: 26px 16px 36px;
  }

  .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .panel {
    padding: 16px;
  }

  #script {
    min-height: clamp(220px, 38vh, 380px);
  }
}

@media (max-width: 370px) {
  .app-header,
  .workspace,
  .panel {
    padding-inline: 12px;
  }
}

.notice {
  margin: 8px 0 0;
  padding: 10px 13px;
  color: #4d4d49;
  background: #f2f2f0;
  border-radius: 9px;
  font-size: .87rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.notice[data-kind="error"],
.notice[data-kind="warning"] {
  color: #8c3528;
  background: var(--accent-soft);
}

.notice[data-kind="success"] {
  color: #216144;
  background: #e5f4ed;
}

.pair-dialog {
  width: min(440px, calc(100% - 26px));
  max-height: calc(100% - 26px);
  padding: 0;
  color: #111;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 20px 70px rgb(0 0 0 / 20%);
}

.pair-dialog::backdrop {
  background: rgb(9 9 9 / 48%);
}

.pair-panel {
  display: grid;
  gap: 14px;
  padding: 21px;
}

.pair-header,
.pair-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.pair-header h2,
.remote-card h1 {
  margin: 0;
  letter-spacing: -.04em;
}

.pair-header .subtle {
  margin: 6px 0 0;
}

.pair-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.pair-status {
  margin: 0;
}

.pair-code {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.pair-code img {
  width: min(212px, 100%);
  height: auto;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.pair-link {
  padding: 7px 9px;
  color: var(--accent-ink);
  font-size: .88rem;
  font-weight: 700;
  text-underline-offset: 3px;
}

.remote-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 15px max(18px, env(safe-area-inset-left));
  min-height: 62px;
  gap: 12px;
  color: #ffffff;
  background: #090909;
}

.remote-header-title {
  color: #dededb;
  font-size: .86rem;
}

.remote-workspace {
  width: min(100%, 520px);
  padding: 22px 16px max(22px, env(safe-area-inset-bottom));
  margin-inline: auto;
}

.remote-card {
  gap: 12px;
}

.remote-card .panel-header {
  margin-bottom: 0;
}

.remote-card h1 {
  font-size: 1.45rem;
}

.remote-status {
  display: grid;
  align-items: center;
  grid-template-columns: auto 1fr;
  gap: 3px 8px;
  padding: 11px 13px;
  color: #4d4d49;
  background: #f2f2f0;
  border-radius: 9px;
  font-size: .85rem;
}

.remote-status > span:last-child {
  grid-column: 2;
  line-height: 1.45;
}

.remote-status[data-state="connected"] {
  color: #216144;
  background: #e5f4ed;
}

.remote-status[data-state="connected"] .remote-status-dot {
  background: #22805f;
}

.remote-monitor,
.remote-paragraph-controls,
.remote-speed-controls,
.remote-font-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.remote-monitor {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
}

.remote-monitor > div {
  padding: 10px clamp(7px, 2vw, 12px);
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.remote-monitor dt {
  color: var(--muted);
  font-size: .8rem;
}

.remote-monitor dd {
  margin: 4px 0 0;
  font-size: clamp(.95rem, 4vw, 1.2rem);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  font-weight: 760;
}

.remote-actions {
  display: grid;
  gap: 8px;
}

.remote-actions .remote-play {
  min-height: 58px;
  font-size: 1.1rem;
}

.remote-footer {
  display: flex;
  justify-content: flex-end;
}

.remote-end {
  color: var(--muted);
}

@media (max-width: 550px) {
  .app-header {
    gap: 8px;
    flex-wrap: wrap;
  }

  .panel {
    padding: 16px;
  }
}
