:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #05070a;
  color: #f7f8fa;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: #05070a;
}

button {
  border: 0;
  font: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: min(100%, 1100px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
}

.intro,
.result {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  text-align: center;
}

.intro > *,
.result > * {
  width: min(100%, 760px);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(30px, 3.4vw, 46px);
  line-height: 1.02;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(28px, 3.2vw, 44px);
}

.subtitle,
#resultMessage {
  color: #b8bdc8;
  font-size: clamp(17px, 2vw, 22px);
}

.primary-button,
.secondary-button {
  width: min(100%, 560px);
  min-height: 92px;
  padding: 18px 32px;
  border-radius: 18px;
  cursor: pointer;
  font-size: clamp(23px, 2.7vw, 31px);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.primary-button {
  margin-top: 30px;
  background: #e31b23;
  color: #fff;
}

.primary-button:active {
  background: #bf151c;
  transform: translateY(1px);
}

.secondary-button {
  margin-top: 14px;
  background: #20242c;
  color: #f7f8fa;
}

.secondary-button:active {
  background: #2c313b;
}

.parking-note {
  margin: 22px auto 0;
  color: #777f8f;
  font-size: 15px;
}

.scanner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.camera-stage {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  border-radius: 20px;
  background: #000;
}

#camera {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-shade {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.scan-frame {
  position: relative;
  height: 82%;
  aspect-ratio: 1;
  background: transparent;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

/* In portrait the stage is taller than it is wide, so width becomes the limit. */
@media (max-aspect-ratio: 1 / 1) {
  .scan-frame {
    height: auto;
    width: 84%;
  }
}

.scan-frame span {
  position: absolute;
  width: 64px;
  height: 64px;
  border-color: #ff4148;
  border-style: solid;
}

.scan-frame span:nth-child(1) {
  top: 0;
  left: 0;
  border-width: 6px 0 0 6px;
  border-radius: 12px 0 0;
}

.scan-frame span:nth-child(2) {
  top: 0;
  right: 0;
  border-width: 6px 6px 0 0;
  border-radius: 0 12px 0 0;
}

.scan-frame span:nth-child(3) {
  right: 0;
  bottom: 0;
  border-width: 0 6px 6px 0;
  border-radius: 0 0 12px;
}

.scan-frame span:nth-child(4) {
  bottom: 0;
  left: 0;
  border-width: 0 0 6px 6px;
  border-radius: 0 0 0 12px;
}

.instruction {
  margin: 14px 0 0;
  color: #f2f4f7;
  font-size: clamp(19px, 2.2vw, 26px);
  font-weight: 700;
}

.tip {
  margin: 6px 0 0;
  color: #8b93a3;
  font-size: 15px;
}

.secondary-button.compact {
  width: auto;
  min-height: 64px;
  margin-top: 12px;
  padding: 12px 56px;
  font-size: 20px;
}

.detected-value {
  display: block;
  max-height: 220px;
  margin: 20px auto 0;
  padding: 20px 22px;
  overflow: auto;
  border: 1px solid #303640;
  border-radius: 14px;
  background: #101318;
  color: #98a0b0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: clamp(15px, 1.5vw, 19px);
  line-height: 1.5;
  overflow-wrap: anywhere;
  user-select: text;
}

.detected-value.is-url {
  text-align: left;
}

.url-host {
  color: #ffffff;
  font-size: 1.45em;
  font-weight: 700;
}

.url-rest {
  color: #b6bdc9;
}

.url-id {
  color: #ffffff;
  font-size: 1.45em;
  font-weight: 700;
}

#resultMessage.is-warning {
  color: #ffc46b;
}

.manual {
  margin-top: 26px;
  text-align: left;
}

.manual-label {
  display: block;
  margin-bottom: 8px;
  color: #8b93a3;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.manual-row {
  display: flex;
  gap: 12px;
}

.manual-input {
  flex: 1;
  min-width: 0;
  min-height: 64px;
  padding: 12px 18px;
  border: 1px solid #2b313b;
  border-radius: 14px;
  background: #101318;
  color: #f7f8fa;
  font: inherit;
  font-size: 22px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.manual-input::placeholder {
  color: #5d6575;
}

.manual-input:focus {
  border-color: #e31b23;
  outline: none;
}

.manual .secondary-button.compact {
  margin-top: 0;
  padding-inline: 34px;
}

.result-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.error {
  width: min(100%, 720px);
  margin: 20px auto;
  padding: 16px 20px;
  border: 1px solid rgba(255, 84, 91, 0.45);
  border-radius: 12px;
  background: rgba(227, 27, 35, 0.12);
  color: #ff9b9f;
  text-align: center;
  font-size: 17px;
}

footer {
  width: 100%;
  padding-top: 16px;
  text-align: center;
}

.debug-toggle {
  min-height: 44px;
  padding: 10px 20px;
  background: transparent;
  color: #737b8b;
  cursor: pointer;
  font-size: 15px;
}

.debug-panel {
  max-width: 900px;
  margin: 8px auto 0;
  padding: 15px;
  border: 1px solid #282d36;
  border-radius: 12px;
  background: #0d1015;
  text-align: left;
}

.debug-panel dl,
.debug-panel dd {
  margin: 0;
}

.debug-panel div {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 14px;
  padding: 5px 0;
}

.debug-panel dt {
  color: #818999;
}

.debug-panel dd {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #c9ced8;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
}

.recent {
  margin-top: 34px;
  text-align: left;
}

.recent-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #232831;
}

.recent-title {
  margin: 0;
  color: #8b93a3;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.text-button {
  padding: 8px 12px;
  background: transparent;
  color: #737b8b;
  cursor: pointer;
  font-size: 15px;
}

.text-button:active {
  color: #f7f8fa;
}

/* The in-car screen is wide, so let saved links sit side by side. */
.recent-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.recent-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 78px;
  padding: 14px 20px;
  border: 1px solid #2b313b;
  border-radius: 14px;
  background: #151921;
  color: #f7f8fa;
  cursor: pointer;
  text-align: left;
}

.recent-item:active {
  background: #1e232c;
}

.recent-label {
  font-size: 23px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.recent-meta {
  color: #8b93a3;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.recent-time {
  color: #6f7788;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

@media (orientation: landscape) and (max-height: 650px) {
  .intro {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(300px, 0.8fr);
    grid-template-rows: repeat(4, auto);
    column-gap: 48px;
    align-items: center;
    text-align: left;
  }

  .intro > * {
    width: auto;
  }

  h1 {
    grid-row: 1 / 5;
    margin: 0;
  }

  .subtitle {
    align-self: end;
    margin-bottom: 10px;
  }

  .primary-button {
    margin-top: 0;
  }

  .parking-note {
    display: none;
  }

  .recent {
    margin-top: 16px;
  }

  .recent-list {
    grid-template-columns: 1fr;
    max-height: 150px;
    overflow-y: auto;
  }

  .recent-item {
    min-height: 62px;
    padding: 10px 16px;
  }

  .recent-label {
    font-size: 19px;
  }

  .manual {
    margin-top: 14px;
  }

  .manual-input {
    min-height: 56px;
    font-size: 19px;
  }

  .primary-button,
  .secondary-button {
    min-height: 76px;
  }

  .detected-value {
    max-height: 120px;
  }
}

@media (max-width: 560px) {
  .app {
    padding-inline: 16px;
  }

  .debug-panel div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
