:root {
  color-scheme: dark;
  --bg: #101418;
  --bg-raised: #182027;
  --line: #26313a;
  --text: #e8eaed;
  --muted: #9aa7b2;
  --accent: #3d8bfd;
  --accent-strong: #2f7ae5;
  --danger: #ff6b6b;
  --radius: 14px;
  --gap: 16px;
}

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

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  padding:
    env(safe-area-inset-top, 0)
    env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0)
    env(safe-area-inset-left, 0);
  overscroll-behavior-y: contain;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px calc(16px + env(safe-area-inset-right, 0)) 10px calc(16px + env(safe-area-inset-left, 0));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar[hidden] {
  display: none;
}

.topbar__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__exit {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
}

.topbar__exit:active {
  background: var(--bg-raised);
}

/* ---------- layout ---------- */

#app {
  display: block;
  padding: 20px calc(16px + env(safe-area-inset-right, 0)) calc(28px + env(safe-area-inset-bottom, 0)) calc(16px + env(safe-area-inset-left, 0));
  max-width: 560px;
  margin: 0 auto;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card--object {
  gap: 8px;
}

.form {
  display: block;
}

.title {
  margin: 0;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.notice {
  margin: 0;
  color: var(--accent);
  font-size: 15px;
}

.error {
  margin: 0;
  color: var(--danger);
  font-size: 15px;
}

.object__address {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.object__number {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

/* ---------- fields ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field[hidden] {
  display: none;
}

.field__label {
  font-size: 14px;
  color: var(--muted);
}

.input {
  appearance: none;
  width: 100%;
  min-height: 54px;
  padding: 14px 16px;
  font: inherit;
  font-size: 17px;
  color: var(--text);
  background: #0c1014;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 139, 253, 0.22);
}

/* ---------- buttons ---------- */

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  padding: 16px 20px;
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
}

.button--primary {
  background: var(--accent);
}

.button--primary:active {
  background: var(--accent-strong);
}

.button--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
  font-weight: 500;
}

.button--ghost:active {
  background: #202932;
}

.button--wide {
  width: 100%;
}

.button:disabled {
  opacity: 0.55;
  cursor: default;
}

/* ---------- player ---------- */

.player {
  width: 100%;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

.player:empty {
  display: none;
}

.player video,
.player iframe,
.player canvas {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: #223040;
  color: var(--text);
  font-size: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 10;
}

.toast[hidden] {
  display: none;
}

.toast--error {
  background: #3a2226;
  color: #ffd9dc;
}

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

@media (min-width: 600px) {
  body {
    font-size: 17px;
  }
  #app {
    padding-top: 28px;
  }
}
