/* Two Way — desert palette. Warm dark ground, sand gold, sunset, oasis.
   Every foreground colour here clears 7:1 against its background, because the
   real constraint is a phone screen in direct sun, not the look in a dark room. */

:root {
  /* Ground: warm near-black, like night sand rather than blue shadow */
  --bg: #0b0805;
  --bg-lift: #140e08;
  --panel: #17110b;
  --panel-2: #221a11;
  --line: #3a2d1e;
  --line-soft: #2a2015;

  /* Type */
  --text: #f8f1e4; /* bleached sand */
  --muted: #a4907a; /* dust */

  /* State */
  --sand: #e9b44c; /* ready / brand */
  --sand-deep: #c28d2c;
  --sunset: #ff5130; /* transmitting */
  --sunset-deep: #a82d15;
  --oasis: #1fc7a9; /* receiving */
  --oasis-deep: #0d6b5c;
  --sky: #7fb2e5; /* links */

  --radius: 18px;
  --radius-lg: 26px;
  --tap: 58px;
}

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

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* A low sun sitting on the horizon, behind the talk button. Deliberately faint:
   it must never cost contrast on the text above it. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 55% at 50% 108%, rgba(233, 180, 76, 0.16), transparent 70%);
  transition: background 0.35s ease;
  z-index: 0;
}
body.tx::before {
  background: radial-gradient(130% 60% at 50% 108%, rgba(255, 81, 48, 0.28), transparent 72%);
}
body.rx::before {
  background: radial-gradient(130% 60% at 50% 108%, rgba(31, 199, 169, 0.2), transparent 72%);
}

body {
  transition: background-color 0.25s ease;
}
body.tx {
  background: #150703;
}
body.rx {
  background: #04120e;
}

.screen {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(18px, env(safe-area-inset-top)) 20px max(22px, env(safe-area-inset-bottom));
  /* Nothing in a single-screen app should ever scroll sideways. */
  overflow-x: hidden;
}
[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ setup -- */

.brand {
  text-align: center;
  margin: 7vh 0 5vh;
}
.logo {
  width: 92px;
  height: 92px;
  display: block;
  margin: 0 auto 16px;
  filter: drop-shadow(0 0 18px rgba(233, 180, 76, 0.35));
}
.brand h1 {
  margin: 0;
  font-size: 31px;
  font-weight: 800;
  letter-spacing: 0.26em;
  text-indent: 0.26em; /* balance the tracking so it reads centred */
}
.tag {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0.06em;
}

.fields {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.field > span {
  font-size: 13px;
  font-weight: 700;
  color: var(--sand);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.field small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.row {
  display: flex;
  gap: 10px;
}
.row #f-code {
  flex: 1;
  letter-spacing: 0.3em;
  font-weight: 800;
  text-transform: uppercase;
}

input[type='text'],
input[type='url'] {
  width: 100%;
  min-height: var(--tap);
  padding: 0 18px;
  font-size: 19px;
  color: var(--text);
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus {
  border-color: var(--sand);
  box-shadow: 0 0 0 4px rgba(233, 180, 76, 0.16);
}
input::placeholder {
  color: #6b5947;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

.primary {
  margin-top: auto;
  min-height: 70px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f3c264, var(--sand) 55%, var(--sand-deep));
  color: #241503;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.18em;
  box-shadow: 0 10px 26px rgba(233, 180, 76, 0.22);
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.primary:active {
  transform: translateY(2px);
  box-shadow: 0 4px 14px rgba(233, 180, 76, 0.18);
}
.primary:disabled {
  opacity: 0.55;
  box-shadow: none;
}

.ghost {
  min-height: var(--tap);
  padding: 0 22px;
  border-radius: var(--radius);
  background: var(--panel-2);
  border: 2px solid var(--line);
  color: var(--sand);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.link {
  align-self: flex-start;
  padding: 12px 0;
  color: var(--sky);
  font-size: 15px;
  font-weight: 600;
}

.msg {
  min-height: 22px;
  margin: 16px 0 0;
  color: var(--sand);
  font-size: 15px;
  text-align: center;
}
.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

/* ------------------------------------------------------------------- room -- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ident {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0; /* let the code ellipsize instead of widening the page */
  flex: 1;
}
.ident.controls {
  flex: none;
}
/* A 12-character channel code must not be able to push the layout sideways. */
.code {
  font-size: clamp(17px, 5.4vw, 23px);
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mode {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  padding: 5px 9px;
  border-radius: 7px;
  border: 1px solid transparent;
}
.mode.online {
  background: rgba(31, 199, 169, 0.14);
  border-color: rgba(31, 199, 169, 0.35);
  color: var(--oasis);
}
.mode.local {
  background: rgba(233, 180, 76, 0.14);
  border-color: rgba(233, 180, 76, 0.4);
  color: var(--sand);
}

.pill {
  font-size: 12px;
  font-weight: 800;
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.pill.online {
  background: rgba(31, 199, 169, 0.14);
  color: var(--oasis);
}
.pill.connecting {
  background: rgba(233, 180, 76, 0.16);
  color: var(--sand);
}
.pill.offline {
  background: rgba(255, 81, 48, 0.16);
  color: var(--sunset);
}

.icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  font-size: 18px;
  color: var(--muted);
  flex: none;
}
.icon:active {
  background: var(--panel-2);
}

.roster-wrap {
  margin-top: 20px;
}
.roster-head {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.roster-head .pill {
  margin-left: auto;
  letter-spacing: 0.02em;
  text-transform: none;
}
.badge {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 2px 10px;
  color: var(--sand);
  font-weight: 800;
}
.roster {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  max-height: 22vh;
  overflow-y: auto;
}
.member {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 15px;
  background: var(--panel);
  border: 2px solid var(--line-soft);
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.member .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #5a4835;
  flex: none;
}
.member.me .dot {
  background: var(--sand);
}
.member.talking {
  border-color: var(--oasis);
  background: rgba(31, 199, 169, 0.12);
}
.member.talking .dot {
  background: var(--oasis);
  box-shadow: 0 0 10px var(--oasis);
  animation: pulse 0.9s ease-in-out infinite;
}
.member .you {
  font-size: 10px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

.statusblock {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 18px 0;
  min-height: 96px;
}
.status {
  font-size: clamp(27px, 8.5vw, 42px);
  font-weight: 900;
  letter-spacing: 0.045em;
  line-height: 1.08;
  word-break: break-word;
}
.substatus {
  margin-top: 8px;
  color: var(--muted);
  font-size: 16px;
  letter-spacing: 0.02em;
}
body.tx .status {
  color: var(--sunset);
  text-shadow: 0 0 26px rgba(255, 81, 48, 0.4);
}
body.rx .status {
  color: var(--oasis);
  text-shadow: 0 0 26px rgba(31, 199, 169, 0.35);
}

/* --------------------------------------------------------------------- PTT -- */

.pttwrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding-bottom: 8px;
}

.ptt {
  position: relative;
  width: min(72vw, 300px);
  height: min(72vw, 300px);
  min-width: 168px;
  min-height: 168px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, var(--panel-2), var(--panel) 70%);
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 0 0 1px rgba(233, 180, 76, 0.08), 0 18px 46px rgba(0, 0, 0, 0.55),
    inset 0 2px 12px rgba(255, 255, 255, 0.03);
  transition: transform 0.09s ease, border-color 0.15s ease, box-shadow 0.2s ease;
}

/* The ring is the whole visual language: colour tells you the channel state
   from arm's length, without reading a word. */
.ptt .ring {
  position: absolute;
  inset: 15px;
  border-radius: 50%;
  border: 15px solid var(--sand);
  box-shadow: 0 0 26px rgba(233, 180, 76, 0.35), inset 0 0 18px rgba(233, 180, 76, 0.18);
  transition: border-color 0.15s ease, box-shadow 0.2s ease;
}
.ptt-label {
  position: relative;
  font-size: clamp(18px, 5.5vw, 27px);
  font-weight: 900;
  letter-spacing: 0.16em;
  color: var(--text);
  text-indent: 0.16em;
}

body.tx .ptt {
  border-color: rgba(255, 81, 48, 0.5);
  transform: scale(0.97);
  box-shadow: 0 0 0 1px rgba(255, 81, 48, 0.2), 0 0 60px rgba(255, 81, 48, 0.3),
    0 12px 34px rgba(0, 0, 0, 0.55);
}
body.tx .ptt .ring {
  border-color: var(--sunset);
  box-shadow: 0 0 34px rgba(255, 81, 48, 0.55), inset 0 0 22px rgba(255, 81, 48, 0.25);
  animation: tx-pulse 1.15s ease-in-out infinite;
}
body.tx .ptt-label {
  color: var(--sunset);
}
@keyframes tx-pulse {
  50% {
    opacity: 0.5;
  }
}

body.rx .ptt {
  border-color: rgba(31, 199, 169, 0.3);
}
body.rx .ptt .ring {
  border-color: var(--oasis-deep);
  box-shadow: 0 0 20px rgba(31, 199, 169, 0.22), inset 0 0 14px rgba(31, 199, 169, 0.12);
}
body.rx .ptt-label {
  color: var(--muted);
}

.ptt.shake {
  animation: shake 0.4s;
}
@keyframes shake {
  10%,
  90% {
    transform: translateX(-5px);
  }
  30%,
  70% {
    transform: translateX(8px);
  }
  50% {
    transform: translateX(-8px);
  }
}

.meter {
  width: min(72vw, 300px);
  height: 9px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sand), var(--sunset));
  transition: width 0.06s linear;
}

/* ---------------------------------------------------------------- settings -- */

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.66);
  display: flex;
  align-items: flex-end;
  z-index: 20;
}
.sheet-inner {
  width: 100%;
  background: var(--bg-lift);
  border-top: 1px solid var(--line);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 10px 20px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: sheet-up 0.22s ease;
}
@keyframes sheet-up {
  from {
    transform: translateY(14%);
    opacity: 0.4;
  }
}
/* Grab handle: signals the sheet is dismissable without adding a control. */
.sheet-inner::before {
  content: '';
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  margin: 4px auto 10px;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.sheet-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--sand);
}

.opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--line-soft);
}
.opt.column {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}
.opt span {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.opt strong {
  font-size: 16px;
  font-weight: 700;
}
.opt small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.opt b {
  color: var(--sand);
}

input[type='checkbox'] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 60px;
  height: 35px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 2px solid var(--line);
  position: relative;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}
input[type='checkbox']::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s ease, background-color 0.18s ease;
}
input[type='checkbox']:checked {
  background: rgba(233, 180, 76, 0.22);
  border-color: var(--sand);
}
input[type='checkbox']:checked::after {
  transform: translateX(25px);
  background: var(--sand);
}

input[type='range'] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 34px;
  background: transparent;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 9px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 32px;
  height: 32px;
  margin-top: -12px;
  border-radius: 50%;
  background: linear-gradient(180deg, #f3c264, var(--sand-deep));
  box-shadow: 0 2px 10px rgba(233, 180, 76, 0.35);
}
input[type='range']::-moz-range-track {
  height: 9px;
  border-radius: 999px;
  background: var(--panel-2);
}
input[type='range']::-moz-range-thumb {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--sand);
}

/* ------------------------------------------------------------------- toast -- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 26px);
  transform: translate(-50%, 20px);
  padding: 14px 22px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 2px solid var(--sand);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
