@font-face {
  font-family: 'Ravi';
  src: url('../fonts/Ravi-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Ravi';
  src: url('../fonts/Ravi-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg-gradient-start: #25D366;
  --bg-gradient-mid: #128C7E;
  --bg-gradient-end: #075E54;
  --card-bg: #ffffff;
  --card-text: #1a1a1a;
  --card-subtext: #555;
  --input-bg: #f8f9fa;
  --input-border: #dee2e6;
  --input-focus: #128C7E;
  --btn-primary-bg: #128C7E;
  --btn-primary-hover: #0e6b60;
  --btn-primary-text: #ffffff;
  --btn-secondary-bg: #e9ecef;
  --btn-secondary-text: #333;
  --topbar-btn-bg: rgba(255, 255, 255, 0.2);
  --topbar-btn-hover: rgba(255, 255, 255, 0.35);
  --topbar-link-bg: rgba(255, 255, 255, 0.15);
  --topbar-link-hover: rgba(255, 255, 255, 0.3);
  --topbar-fg: #ffffff;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  --toast-error-bg: #fff1f0;
  --toast-error-text: #9b2c2c;
  --toast-error-border: #f5b5b0;
  --toast-success-bg: #e9f8ef;
  --toast-success-text: #0e6b60;
  --toast-success-border: #9fdcbd;
  --link-color: #128C7E;
  --qr-dark: #000;
  --qr-light: #fff;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg-gradient-start: #1a2428;
  --bg-gradient-mid: #141c1f;
  --bg-gradient-end: #0e1416;
  --card-bg: #232f35;
  --card-text: #f0f0f0;
  --card-subtext: #a8b4ba;
  --input-bg: #2c3a42;
  --input-border: #3d4f58;
  --input-focus: #3ecf8e;
  --btn-primary-bg: #0a7a4b;
  --btn-primary-hover: #096b42;
  --btn-primary-text: #ffffff;
  --btn-secondary-bg: #2c3a42;
  --btn-secondary-text: #e8eef1;
  --topbar-btn-bg: rgba(255, 255, 255, 0.08);
  --topbar-btn-hover: rgba(255, 255, 255, 0.14);
  --topbar-link-bg: rgba(255, 255, 255, 0.08);
  --topbar-link-hover: rgba(255, 255, 255, 0.14);
  --topbar-fg: #e8eef1;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --toast-error-bg: #3a2c2e;
  --toast-error-text: #ffb4b4;
  --toast-error-border: #6e3f44;
  --toast-success-bg: #1e3329;
  --toast-success-text: #8bdeb0;
  --toast-success-border: #2f6b52;
  --link-color: #5dca8a;
  --qr-dark: #fff;
  --qr-light: #232f35;
}

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

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: 'Ravi', system-ui, sans-serif;
  background-color: var(--bg-gradient-end);
  color: var(--card-text);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--bg-gradient-end);
  background-image: linear-gradient(43deg, var(--bg-gradient-start) 0%, var(--bg-gradient-mid) 50%, var(--bg-gradient-end) 100%);
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
}

.top-bar {
  width: 100%;
  max-width: 420px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.icon-btn {
  background: var(--topbar-btn-bg);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  color: var(--topbar-fg);
}

.icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex-shrink: 0;
}

.icon-btn .icon {
  display: block;
}

.icon-btn .icon-sun {
  display: none;
}

[data-theme="dark"] .icon-btn .icon-moon {
  display: none;
}

[data-theme="dark"] .icon-btn .icon-sun {
  display: block;
}

.chevron-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
  color: var(--card-subtext);
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--topbar-btn-hover);
}

.lang-link {
  color: var(--topbar-fg);
  text-decoration: none;
  font-weight: bold;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  background: var(--topbar-link-bg);
  font-size: 0.9rem;
}

.lang-link:hover {
  background: var(--topbar-link-hover);
}

.container {
  width: 100%;
  max-width: 420px;
}

.card {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: visible;
  position: relative;
}

.card-body {
  padding: 1.25rem 1.5rem 1.5rem;
}

.card-title {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: bold;
  text-align: center;
  color: var(--card-text);
}

.card-subtitle {
  margin: 0 0 1.25rem;
  text-align: center;
  color: var(--card-subtext);
  font-size: 0.95rem;
}

.field {
  margin-bottom: 1rem;
}

.field-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--card-text);
}

.hint {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--card-subtext);
}

.input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid var(--input-border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--card-text);
  transition: border-color 0.2s;
}

.input:focus {
  outline: none;
  border-color: var(--input-focus);
}

.input-ltr {
  direction: ltr;
  text-align: left;
}

.textarea {
  resize: vertical;
  min-height: 60px;
}

.country-select {
  position: relative;
  z-index: 1;
}

.country-select.is-open {
  z-index: 300;
}

.country-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid var(--input-border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--card-text);
  cursor: pointer;
  text-align: inherit;
}

.country-trigger:hover {
  border-color: var(--input-focus);
}

.country-trigger img {
  border-radius: 2px;
  flex-shrink: 0;
}

.country-trigger #country-label {
  flex: 1;
  text-align: inherit;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.country-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--card-bg);
  border: 2px solid var(--input-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: min(280px, 50vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.country-dropdown[hidden] {
  display: none !important;
}

.country-search {
  padding: 0.6rem 0.75rem;
  border: none;
  border-bottom: 1px solid var(--input-border);
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--input-bg);
  color: var(--card-text);
  border-radius: 8px 8px 0 0;
}

.country-search:focus {
  outline: none;
}

.country-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
}

.country-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--card-text);
}

.country-list li:hover,
.country-list li:focus,
.country-list li.is-active {
  background: var(--input-bg);
  outline: none;
}

.country-list img {
  border-radius: 2px;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-weight: bold;
  font-family: inherit;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.18);
}

.btn-primary:hover:not(:disabled) {
  background: var(--btn-primary-hover);
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  font-size: 0.9rem;
  padding: 0.65rem 0.75rem;
}

.btn-secondary:hover:not(:disabled) {
  filter: brightness(0.95);
}

.actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.actions-row-3 {
  grid-template-columns: repeat(3, 1fr);
}

.btn-ghost {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.55rem;
  background: transparent;
  border: none;
  color: var(--link-color);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

.history-list-stars {
  flex-direction: column;
  align-items: stretch;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.history-item .history-chip {
  flex: 1;
}

.history-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--card-subtext);
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  line-height: 1;
}

.history-star.is-favorite {
  color: #e6b800;
}

.history-star:hover {
  color: #e6b800;
}

.favorite-item {
  display: flex;
}

.favorite-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 999px;
  overflow: hidden;
}

.favorite-chip-number {
  border: none;
  background: transparent;
  padding: 0.45rem 0.65rem 0.45rem 0.85rem;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--card-text);
  cursor: pointer;
  text-align: start;
  direction: ltr;
}

.favorite-chip-remove {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  margin-inline: 0.15rem 0.35rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--card-subtext);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.favorite-chip-remove:hover {
  background: var(--toast-error-bg);
  color: var(--toast-error-text);
}

.favorite-chip-remove:focus-visible {
  outline: 2px solid var(--input-focus);
  outline-offset: 1px;
}

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

  .toast {
    transform: none;
    transition: opacity 0.01ms;
  }

  .toast.is-visible {
    transform: none;
  }
}

.toast {
  position: fixed;
  inset-inline: 1rem;
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  z-index: 1000;
  display: flex;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(1.25rem) scale(0.96);
  transition:
    opacity 0.32s ease,
    transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.toast-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: min(100%, 22rem);
  padding: 0.85rem 0.9rem 1rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  border: 1px solid transparent;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.toast-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
}

.toast-message {
  flex: 1;
  text-align: start;
}

.toast-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  opacity: 0.65;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}

.toast-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .toast-close:hover {
  background: rgba(255, 255, 255, 0.08);
}

.toast-progress {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 3px;
  background: currentColor;
  opacity: 0.4;
  animation: toast-progress linear forwards;
}

html[dir="rtl"] .toast-progress {
  transform-origin: right;
}

html[dir="ltr"] .toast-progress {
  transform-origin: left;
}

@keyframes toast-progress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.toast-error .toast-inner {
  background: var(--toast-error-bg);
  color: var(--toast-error-text);
  border-color: var(--toast-error-border);
}

.toast-error .toast-icon {
  background: rgba(155, 44, 44, 0.12);
  color: var(--toast-error-text);
}

.toast-success .toast-inner {
  background: var(--toast-success-bg);
  color: var(--toast-success-text);
  border-color: var(--toast-success-border);
}

.toast-success .toast-icon {
  background: rgba(14, 107, 96, 0.12);
  color: var(--toast-success-text);
}

[data-theme="dark"] .toast-error .toast-icon {
  background: rgba(255, 180, 180, 0.1);
}

[data-theme="dark"] .toast-success .toast-icon {
  background: rgba(139, 222, 176, 0.1);
}

.qr-section {
  margin-top: 1rem;
  text-align: center;
}

.qr-title {
  font-size: 0.85rem;
  color: var(--card-subtext);
  margin: 0 0 0.5rem;
}

.qr-canvas {
  display: inline-block;
  padding: 0.75rem;
  background: var(--qr-light);
  border-radius: 8px;
}

.qr-table {
  border-collapse: collapse;
}

.qr-table td {
  padding: 0;
}

.qr-dark {
  background: var(--qr-dark);
}

.history-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--input-border);
}

.section-title {
  font-size: 0.9rem;
  margin: 0 0 0.5rem;
  color: var(--card-subtext);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.history-chip {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  border: none;
  border-radius: 20px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  direction: ltr;
}

.history-chip:hover {
  filter: brightness(0.93);
}

.btn-link {
  background: none;
  border: none;
  color: var(--link-color);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  margin-top: 0.5rem;
  padding: 0;
  text-decoration: underline;
}

.card-footer {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.85rem;
}

.card-footer a {
  color: var(--link-color);
  text-decoration: none;
}

.card-footer a:hover {
  text-decoration: underline;
}

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

[hidden] {
  display: none !important;
}

/* Content pages (FAQ, Privacy) */
.content-page {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  color: var(--card-text);
  line-height: 1.7;
}

.content-page h1 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
}

.content-page h2 {
  font-size: 1.05rem;
  margin: 1.25rem 0 0.5rem;
}

.content-page p,
.content-page li {
  color: var(--card-subtext);
  font-size: 0.95rem;
}

.content-page code {
  background: var(--input-bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85rem;
  direction: ltr;
  display: inline-block;
}

.content-page .updated {
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.back-link {
  display: inline-block;
  color: var(--link-color);
  text-decoration: none;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.back-link:hover {
  text-decoration: underline;
}

.content-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--input-border);
  text-align: center;
  font-size: 0.85rem;
}

.content-footer a {
  color: var(--link-color);
  text-decoration: none;
}

.content-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 380px) {
  .card-body {
    padding: 1rem;
  }

  .actions-row,
  .actions-row-3 {
    grid-template-columns: 1fr;
  }
}
