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

:root {
  --bg:     #f5f5f5;
  --card:   #fff;
  --border: #e0e0e0;
  --text:   #1a1a1a;
  --sub:    #666;
  --muted:  #999;
  --blue:   #2563eb;
  --blue-h: #1d4ed8;
  --blue-bg:#eff6ff;
  --green:  #16a34a;
  --red:    #dc2626;
  --mono:   'JetBrains Mono', monospace;
  --sans:   'Inter', system-ui, -apple-system, sans-serif;
  --radius: 8px;
}

html { font-size: 16px; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
}

.app {
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ─── Header ─── */
.header {
  margin-bottom: 1.5rem;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -.02em;
}

.subtitle {
  font-size: .9rem;
  color: var(--sub);
}

/* ─── Toolbar ─── */
.toolbar {
  display: flex;
  gap: .75rem;
  margin-bottom: 1.5rem;
}

/* Country select / search */
.select-wrap {
  flex: 1;
  position: relative;
}

.select-wrap input {
  width: 100%;
  font-family: var(--sans);
  font-size: 1rem;
  padding: .65rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}

.select-wrap input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 12%, transparent);
}

.select-wrap input.has-value {
  font-weight: 500;
}

/* Dropdown */
.dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
  z-index: 100;
  overflow: hidden;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.tab {
  all: unset;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 500;
  padding: .25rem .6rem;
  border-radius: 4px;
  color: var(--sub);
  transition: background .1s, color .1s;
}

.tab:hover { background: var(--border); color: var(--text); }
.tab.active { background: var(--blue); color: #fff; }

.list {
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.opt {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem 1rem;
  cursor: pointer;
  font-size: .95rem;
  transition: background .08s;
}

.opt:hover { background: var(--blue-bg); }
.opt.active { background: var(--blue-bg); font-weight: 500; }
.opt[hidden] { display: none; }

.opt .code {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--muted);
  min-width: 2rem;
  text-transform: uppercase;
}

.opt .name { flex: 1; }

.opt .dial {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--muted);
}

/* Generate button */
.btn-gen {
  all: unset;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 500;
  padding: .65rem 1.4rem;
  border-radius: var(--radius);
  background: var(--blue);
  color: #fff;
  white-space: nowrap;
  transition: background .12s, opacity .12s;
  flex-shrink: 0;
}

.btn-gen:hover { background: var(--blue-h); }
.btn-gen:disabled { opacity: .4; cursor: default; }
.btn-gen:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ─── Result Card ─── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.placeholder {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  font-size: 1rem;
}

.row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.row:last-child { border-bottom: none; }

.label {
  font-size: .82rem;
  font-weight: 500;
  color: var(--sub);
  min-width: 3.2rem;
  flex-shrink: 0;
}

.value {
  flex: 1;
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
  user-select: all;
}

.btn-copy {
  all: unset;
  cursor: pointer;
  padding: .3rem;
  border-radius: 4px;
  color: var(--muted);
  transition: color .12s, background .12s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.btn-copy:hover { color: var(--blue); background: var(--blue-bg); }
.btn-copy.ok { color: var(--green); }
.btn-copy:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.info {
  font-size: .85rem;
  color: var(--sub);
}

.btn-copyall {
  all: unset;
  cursor: pointer;
  font-family: var(--sans);
  font-size: .88rem;
  font-weight: 500;
  padding: .4rem .9rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--card);
  transition: background .12s, border-color .12s;
}

.btn-copyall:hover { background: var(--bg); border-color: var(--blue); color: var(--blue); }
.btn-copyall:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ─── Spinner ─── */
.spinner {
  align-items: center;
  justify-content: center;
  gap: .6rem;
  padding: 2rem;
  color: var(--sub);
  font-size: .95rem;
  display: none;
}

.spinner:not([hidden]) {
  display: flex;
}

.spin-ring {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Error ─── */
.error {
  text-align: center;
  padding: 1rem;
  color: var(--red);
  font-size: .95rem;
}

/* ─── Responsive ─── */
@media (max-width: 480px) {
  .app { padding: 1.2rem 1rem; }
  .toolbar { flex-direction: column; }
  .btn-gen { text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .spin-ring { animation: none; }
}
