/* ==========================================================================
   KoneProxy styles
   Dark theme by default, optional light theme via [data-theme="light"].
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg: #0a0d13;
  --bg-glow: #101927;
  --surface: #111823;
  --surface-2: #16202d;
  --surface-3: #1c2736;
  --border: #243040;
  --border-strong: #33455c;

  --text: #e9eff8;
  --text-muted: #9aa9bd;
  --text-faint: #71829a;

  --accent: #6aa6ff;
  --accent-strong: #8dbcff;
  --accent-ink: #08111f;
  --accent-soft: rgba(106, 166, 255, 0.14);
  --accent-line: rgba(106, 166, 255, 0.42);

  --danger: #ff8b8b;
  --danger-soft: rgba(255, 116, 116, 0.12);
  --danger-line: rgba(255, 116, 116, 0.38);
  --success: #61d3a4;

  --radius-sm: 9px;
  --radius: 13px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 24px 48px -32px rgba(0, 0, 0, 0.95);

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --toolbar-height: 62px;
}

[data-theme="light"] {
  color-scheme: light;

  --bg: #f4f7fb;
  --bg-glow: #e6eefb;
  --surface: #ffffff;
  --surface-2: #f2f6fb;
  --surface-3: #e8eef7;
  --border: #dbe3ee;
  --border-strong: #c3d0e2;

  --text: #16202d;
  --text-muted: #55657a;
  --text-faint: #7b8ca1;

  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-line: rgba(37, 99, 235, 0.32);

  --danger: #c92a2a;
  --danger-soft: rgba(201, 42, 42, 0.08);
  --danger-line: rgba(201, 42, 42, 0.28);
  --success: #0f7b57;

  --shadow-sm: 0 1px 2px rgba(16, 32, 56, 0.06);
  --shadow-md: 0 24px 48px -34px rgba(16, 32, 56, 0.35);
}

/* -------------------------------------------------------------------------- */
/* Base                                                                       */
/* -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image: radial-gradient(1100px 460px at 50% -12%, var(--bg-glow) 0%, transparent 72%);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
ul,
dl,
dd {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.16s ease;
}

a:hover {
  color: var(--accent-strong);
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.12em 0.36em;
  border-radius: 6px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  word-break: break-word;
}

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

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

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 40;
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  transition: top 0.16s ease;
}

.skip-link:focus {
  top: 0.8rem;
}

/* -------------------------------------------------------------------------- */
/* Header / footer                                                            */
/* -------------------------------------------------------------------------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.15rem 1.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 650;
  letter-spacing: -0.012em;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(160deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: var(--accent-ink);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.brand-name {
  font-size: 1.02rem;
}

.brand-inline {
  margin-bottom: 1.35rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-link {
  padding: 0.42rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface-2);
}

.site-footer {
  padding: 1.6rem 1.5rem 2.1rem;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.83rem;
}

.site-footer a {
  color: var(--text-muted);
}

.site-footer a:hover {
  color: var(--text);
}

/* -------------------------------------------------------------------------- */
/* Buttons / inputs                                                           */
/* -------------------------------------------------------------------------- */

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.icon-button:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.icon-button:active {
  transform: translateY(1px);
}

.icon-button-sm {
  width: 28px;
  height: 28px;
}

.icon-button-sm svg {
  width: 15px;
  height: 15px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.93rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.12s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-sm {
  min-height: 36px;
  padding: 0 0.95rem;
  font-size: 0.88rem;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--accent-ink);
}

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface-3);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn[disabled] {
  opacity: 0.65;
  cursor: progress;
}

.text-input,
.select-input,
.address-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.96rem;
  padding: 0.68rem 0.85rem;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.text-input::placeholder,
.address-input::placeholder {
  color: var(--text-faint);
}

.text-input:focus,
.select-input:focus,
.address-input:focus {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.select-input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) calc(50% + 2px), calc(100% - 15px) calc(50% + 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.4rem;
}

.input-block {
  display: block;
}

/* -------------------------------------------------------------------------- */
/* Homepage                                                                   */
/* -------------------------------------------------------------------------- */

.home-main {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 2rem 1.5rem 3.5rem;
}

.hero {
  width: 100%;
  max-width: 660px;
  text-align: center;
}

.hero-eyebrow {
  margin-bottom: 0.85rem;
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero-title {
  font-size: clamp(2.3rem, 6vw, 3.1rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.06;
}

.hero-tagline {
  margin-top: 0.65rem;
  margin-bottom: 2rem;
  color: var(--text-muted);
  font-size: clamp(1rem, 2vw, 1.12rem);
}

.form-stack {
  margin-bottom: 0.7rem;
}

.input-shell {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.42rem 0.42rem 0.42rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.input-shell:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-sm);
}

.input-shell-quiet {
  border-color: var(--border);
  background: var(--surface-2);
}

.input-icon {
  display: inline-grid;
  place-items: center;
  color: var(--text-faint);
  flex: 0 0 auto;
}

.input-icon svg {
  width: 19px;
  height: 19px;
}

.input-shell .text-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0.5rem 0.15rem;
  font-size: 1rem;
}

.input-shell .text-input:focus {
  box-shadow: none;
}

.input-shell .btn {
  flex: 0 0 auto;
}

.hero-note {
  margin-top: 1.35rem;
  color: var(--text-faint);
  font-size: 0.86rem;
  line-height: 1.6;
}

.alert {
  margin-top: 1.2rem;
  padding: 0.72rem 0.95rem;
  border: 1px solid var(--danger-line);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.9rem;
  text-align: left;
  animation: fade-in 0.2s ease both;
}

.examples {
  margin-top: 1.8rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--border);
}

.examples-label {
  display: block;
  margin-bottom: 0.7rem;
  color: var(--text-faint);
  font-size: 0.76rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
}

.chip {
  padding: 0.34rem 0.72rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.82rem;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-3);
}

/* -------------------------------------------------------------------------- */
/* Content pages (about, privacy, settings)                                   */
/* -------------------------------------------------------------------------- */

.page-main {
  flex: 1;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3.5rem;
}

.page-heading {
  margin-bottom: 1.8rem;
}

.page-heading h1 {
  font-size: clamp(1.7rem, 4vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.page-heading p {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.96rem;
  max-width: 62ch;
}

.card {
  padding: 1.4rem 1.45rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.card h2 {
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.card-header {
  margin-bottom: 1.15rem;
}

.card-header p {
  margin-top: 0.3rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.card-actions {
  margin-top: 1.2rem;
}

.field-group {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.field-label {
  display: block;
  margin-bottom: 0.45rem;
  padding: 0;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
}

.field-help {
  margin-top: 0.5rem;
  color: var(--text-faint);
  font-size: 0.8rem;
}

.field-help.is-warn {
  color: var(--danger);
}

.field-help.is-error {
  color: var(--danger);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}

.segmented-option {
  position: relative;
  display: inline-flex;
}

.segmented-option input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.segmented-option span {
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 600;
  transition: background 0.16s ease, color 0.16s ease;
}

.segmented-option input:checked + span {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.segmented-option input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.info-list {
  display: grid;
  gap: 0;
}

.info-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.62rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.info-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.info-row dt {
  color: var(--text-muted);
}

.info-row dd {
  color: var(--text);
  font-weight: 550;
  text-align: right;
  word-break: break-word;
}

.privacy-list {
  display: grid;
  gap: 0.55rem;
  padding-left: 1.1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.privacy-list li::marker {
  color: var(--accent);
}

.page-footer-note {
  margin-top: 1.5rem;
  color: var(--text-faint);
  font-size: 0.84rem;
  text-align: center;
}

.prose .card p + h2,
.prose .card ul + h2 {
  margin-top: 1.5rem;
}

.prose .card h2 {
  margin-bottom: 0.5rem;
}

.prose .card p {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.6rem;
  transform: translateX(-50%);
  padding: 0.55rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.85rem;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.2s ease both;
  z-index: 30;
}

/* -------------------------------------------------------------------------- */
/* Proxy browser                                                              */
/* -------------------------------------------------------------------------- */

.page-browser {
  height: 100dvh;
  overflow: hidden;
  background-image: none;
}

.browser-toolbar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  min-height: var(--toolbar-height);
}

.browser-group {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  flex: 0 0 auto;
}

.address-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 320px;
  min-width: 0;
  padding: 0.24rem 0.24rem 0.24rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.address-form:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.address-badge {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--text-faint);
}

.address-badge svg {
  width: 15px;
  height: 15px;
}

.address-badge[data-scheme="http"] {
  color: var(--danger);
}

.address-input {
  flex: 1;
  min-width: 0;
  padding: 0.32rem 0.1rem;
  border: 0;
  background: transparent;
  font-size: 0.88rem;
  font-family: var(--font-mono);
}

.address-input:focus {
  box-shadow: none;
}

.browser-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 1 auto;
  min-width: 0;
}

.page-title {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.status-pill {
  padding: 0.16rem 0.55rem;
  border: 1px solid var(--danger-line);
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.loading-track {
  height: 2px;
  overflow: hidden;
  background: transparent;
  flex: 0 0 auto;
}

.loading-thumb {
  display: block;
  height: 100%;
  width: 30%;
  background: var(--accent);
  border-radius: 999px;
  animation: loading-slide 1.1s ease-in-out infinite;
}

.browser-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--bg);
}

.proxy-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.browser-notice {
  position: absolute;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: min(92vw, 640px);
  padding: 0.5rem 0.6rem 0.5rem 0.95rem;
  border: 1px solid var(--danger-line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--danger);
  font-size: 0.85rem;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.2s ease both;
  z-index: 20;
}

/* -------------------------------------------------------------------------- */
/* Error pages                                                                */
/* -------------------------------------------------------------------------- */

.error-page {
  justify-content: center;
  align-items: center;
  padding: 2rem 1.25rem;
}

.error-card {
  width: 100%;
  max-width: 560px;
  padding: 1.7rem 1.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.error-eyebrow {
  color: var(--text-faint);
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.error-title {
  margin: 0.55rem 0 0.7rem;
  font-size: clamp(1.4rem, 4vw, 1.75rem);
  font-weight: 680;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.error-body {
  color: var(--text-muted);
  font-size: 0.94rem;
}

.error-hint {
  margin-top: 0.7rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.error-target {
  margin-top: 1rem;
  color: var(--text-faint);
  font-size: 0.82rem;
  word-break: break-word;
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.error-note {
  margin-top: 1.4rem;
  color: var(--text-faint);
  font-size: 0.75rem;
}

/* -------------------------------------------------------------------------- */
/* Animations                                                                 */
/* -------------------------------------------------------------------------- */

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes loading-slide {
  0% {
    transform: translateX(-110%);
  }
  55% {
    transform: translateX(120%);
  }
  100% {
    transform: translateX(360%);
  }
}

.hero > * {
  animation: rise-in 0.45s cubic-bezier(0.22, 0.7, 0.3, 1) both;
}

.hero > *:nth-child(2) {
  animation-delay: 0.04s;
}
.hero > *:nth-child(3) {
  animation-delay: 0.08s;
}
.hero > *:nth-child(4) {
  animation-delay: 0.12s;
}
.hero > *:nth-child(5) {
  animation-delay: 0.16s;
}
.hero > *:nth-child(6) {
  animation-delay: 0.2s;
}
.hero > *:nth-child(7) {
  animation-delay: 0.24s;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* -------------------------------------------------------------------------- */
/* Responsive                                                                 */
/* -------------------------------------------------------------------------- */

@media (max-width: 860px) {
  .browser-meta .page-title {
    display: none;
  }
}

@media (max-width: 720px) {
  .site-header {
    padding: 0.9rem 1.1rem;
  }

  .home-main {
    padding: 1.2rem 1.1rem 2.6rem;
  }

  .hero-tagline {
    margin-bottom: 1.6rem;
  }

  .input-shell {
    flex-wrap: wrap;
  }

  .input-shell .btn {
    width: 100%;
    margin-top: 0.15rem;
  }

  .input-shell {
    padding: 0.55rem;
    gap: 0.45rem;
  }

  .input-icon {
    margin-left: 0.3rem;
  }

  .page-main {
    padding: 1rem 1.1rem 2.8rem;
  }

  .card {
    padding: 1.15rem 1.1rem;
    border-radius: var(--radius);
  }

  .browser-toolbar {
    gap: 0.45rem;
    padding: 0.5rem;
  }

  .address-form {
    order: 3;
    flex-basis: 100%;
  }

  .browser-meta {
    margin-left: auto;
  }

  .error-card {
    padding: 1.35rem 1.2rem;
  }
}

@media (max-width: 420px) {
  .nav-link {
    padding: 0.42rem 0.4rem;
  }

  .hero-note {
    font-size: 0.82rem;
  }
}
