/* ============================================
   Profilestore — Theme & Reset
   ============================================ */

:root {
  /* Light theme */
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eceef2;
  --text: #11151c;
  --text-muted: #5b6573;
  --text-soft: #8a93a3;
  --border: #e3e7ee;
  --border-strong: #d2d7e0;

  --primary: #4f46e5;       /* indigo */
  --primary-600: #4338ca;
  --primary-soft: #eef0ff;
  --accent: #06b6d4;        /* cyan */
  --danger: #ef4444;
  --success: #10b981;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 1px rgba(15, 23, 42, .02);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, .06), 0 2px 4px rgba(15, 23, 42, .04);
  --shadow-lg: 0 18px 40px rgba(15, 23, 42, .10), 0 4px 10px rgba(15, 23, 42, .04);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --gradient-cover: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  --gradient-accent: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);

  --header-h: 60px;
  --container-max: 1080px;
}

[data-theme="dark"] {
  --bg: #0b0f17;
  --surface: #141a24;
  --surface-2: #1a2230;
  --surface-3: #232c3c;
  --text: #f1f3f7;
  --text-muted: #a3adbe;
  --text-soft: #6f7a8b;
  --border: #232c3c;
  --border-strong: #2d3849;

  --primary: #818cf8;
  --primary-600: #6366f1;
  --primary-soft: #1f2540;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, .45);

  --gradient-cover: linear-gradient(135deg, #312e81 0%, #1e1b4b 60%, #4c1d95 100%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom, 0);
  transition: background-color .3s ease, color .3s ease;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

a { color: inherit; text-decoration: none; }

img { display: block; max-width: 100%; }

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
  font-size: 22px;
  line-height: 1;
  user-select: none;
}

/* ============================================
   Top App Bar
   ============================================ */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(12px);
}

.app-bar__title {
  margin: 0;
  font-family: 'Manrope', 'Noto Sans Thai', sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text);
  transition: background-color .2s ease, transform .15s ease;
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn:active { transform: scale(.92); }

.icon-btn--text {
  width: auto;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: 'Manrope', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.icon-btn--text:hover { background: var(--surface-3); }

.app-bar__actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ============================================
   Layout (mobile-first; expands on desktop)
   ============================================ */
.layout {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 20px 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 900px) {
  .layout {
    grid-template-columns: 380px 1fr;
    gap: 28px;
    padding: 32px 24px;
    align-items: start;
  }
  .profile-card { position: sticky; top: calc(var(--header-h) + 24px); }
}

.details {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ============================================
   Profile Card
   ============================================ */
.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.profile-cover {
  height: 120px;
  background: var(--gradient-cover);
  background-size: 200% 200%;
  animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.profile-card__body {
  padding: 0 24px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.avatar {
  position: relative;
  width: 120px;
  height: 120px;
  margin-top: -60px;
  border-radius: 50%;
  overflow: hidden;
  border: 5px solid var(--surface);
  box-shadow: var(--shadow-lg);
  background: var(--surface-3);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar__status {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--success);
  border: 3px solid var(--surface);
  z-index: 2;
}

.profile-name {
  margin: 16px 0 4px;
  font-family: 'Manrope', 'Noto Sans Thai', sans-serif;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.profile-role {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.01em;
}

.profile-bio {
  margin: 12px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  max-width: 320px;
}

/* Stats */
.stats {
  margin-top: 20px;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 14px 8px;
  border: 1px solid var(--border);
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.stat + .stat::before {
  content: '';
  position: absolute;
  left: 0;
  top: 15%;
  height: 70%;
  width: 1px;
  background: var(--border-strong);
}
.stat__num {
  font-family: 'Manrope', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.stat__label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

/* Actions */
.profile-actions {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform .15s ease, box-shadow .2s ease, background-color .2s ease, color .2s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }

.btn--primary {
  background: var(--gradient-accent);
  color: #fff;
  box-shadow: 0 8px 20px rgba(79, 70, 229, .25);
}
.btn--primary:hover { box-shadow: 0 10px 24px rgba(79, 70, 229, .35); }
.btn--primary.is-active {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: none;
}

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

.btn--accent {
  background: var(--text);
  color: var(--surface);
}
.btn--accent:hover { opacity: .9; }

.btn--full { width: 100%; margin-top: 12px; height: 48px; }

/* ============================================
   Card
   ============================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.section-title {
  margin: 0 0 14px;
  font-family: 'Manrope', 'Noto Sans Thai', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ============================================
   Contact Items
   ============================================ */
.contact-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-md);
  text-align: left;
  transition: background-color .2s ease, transform .15s ease;
}
.contact-item + .contact-item { margin-top: 4px; }
.contact-item:hover { background: var(--surface-2); }
.contact-item:active { transform: scale(.99); }

.contact-item__icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .08);
}

.contact-item__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.contact-item__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.contact-item__value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-item__chev {
  color: var(--text-soft);
  font-size: 20px;
  flex-shrink: 0;
}
.contact-item:hover .contact-item__chev { color: var(--primary); }

/* ============================================
   Social Links
   ============================================ */
.social-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 560px) {
  .social-list { grid-template-columns: 1fr 1fr; }
}

.social-btn {
  --brand: #4f46e5;
  display: flex;
  align-items: stretch;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: transform .15s ease, box-shadow .25s ease, border-color .2s ease, background-color .2s ease;
  position: relative;
  overflow: hidden;
}

.social-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--brand);
  opacity: 0;
  transition: opacity .25s ease;
  z-index: 0;
  pointer-events: none;
}
.social-btn:hover::before { opacity: 0.06; }
.social-btn:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .08);
}
.social-btn:active { transform: translateY(0); }

.social-btn__link {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  min-width: 0;
  position: relative;
  z-index: 1;
  color: inherit;
  text-decoration: none;
}

.social-btn__icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.social-btn__name {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.social-btn__ext {
  color: var(--text-soft);
  font-size: 18px;
  flex-shrink: 0;
}
.social-btn:hover .social-btn__ext { color: var(--brand); }

.social-btn__qr {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  flex-shrink: 0;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease, transform .12s ease;
}
.social-btn__qr:hover { background: var(--brand); color: #fff; }
.social-btn__qr:active { transform: scale(.92); }
.social-btn__qr .material-symbols-outlined { font-size: 22px; }

/* ============================================
   Toast
   ============================================ */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--surface);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 100;
  max-width: 90vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   Settings Page — Form Controls
   ============================================ */
.settings-layout {
  grid-template-columns: 1fr !important;
  max-width: 720px;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group + .form-group { margin-top: 14px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.form-input {
  display: block;
  width: 100%;
  padding: 11px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font: inherit;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .2s ease, background-color .2s ease;
  resize: vertical;
}
.form-input::placeholder { color: var(--text-soft); }
.form-input:hover { border-color: var(--border-strong); }
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
  background: var(--surface);
}

textarea.form-input {
  font-family: inherit;
  line-height: 1.5;
  min-height: 60px;
}

.form-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
  margin-top: 14px;
}
.form-row.form-row--3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row .form-group { margin-top: 0; }

@media (max-width: 480px) {
  .form-row.form-row--3 { grid-template-columns: 1fr; }
}

/* Logo Preview */
.logo-preview {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.logo-preview img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--surface);
  box-shadow: var(--shadow-md);
  background: var(--surface-3);
}

/* Segmented control (theme) */
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
}
.segmented--two { grid-template-columns: repeat(2, 1fr); }

.seg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  background: transparent;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease, transform .12s ease;
}
.seg:hover { color: var(--text); }
.seg:active { transform: scale(.97); }
.seg.is-active {
  background: var(--gradient-accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, .3);
}

/* Settings footer (sticky save bar) */
.settings-footer {
  position: sticky;
  bottom: 16px;
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  margin-top: 8px;
  z-index: 10;
}
.settings-footer .btn { width: 100%; }

/* ============================================
   Links Editor (Settings)
   ============================================ */
.section-hint {
  margin: -8px 0 14px;
  font-size: 12px;
  color: var(--text-soft);
}

.links-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.links-empty {
  padding: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}

.link-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.link-row:hover { border-color: var(--border-strong); }
.link-row:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}

.link-row__preview {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
  transition: background-color .2s ease, transform .15s ease, box-shadow .2s ease;
  flex-shrink: 0;
  cursor: pointer;
}
.link-row__preview:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
}
.link-row__preview:active { transform: scale(.96); }
.link-row__preview .material-symbols-outlined { font-size: 22px; }

.link-row__preview-img,
.social-btn__icon img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.social-btn__icon { position: relative; overflow: hidden; }

.link-row__preview-edit {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .15);
  border: 1px solid var(--border);
}
.link-row__preview-edit .material-symbols-outlined { font-size: 12px; }

.link-row__inputs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.form-input--sm {
  padding: 8px 12px;
  font-size: 14px;
  border-radius: 10px;
}

.link-row__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.link-row__move {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.icon-btn--sm {
  width: 26px;
  height: 26px;
  border-radius: 8px;
}
.icon-btn--sm .material-symbols-outlined { font-size: 18px; }

.icon-btn--danger { color: var(--danger); }
.icon-btn--danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }

/* Color picker (compact) */
.color-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  overflow: hidden;
  transition: background-color .2s ease;
}
.color-picker:hover { background: var(--surface-3); }
.color-picker input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  padding: 0;
  cursor: pointer;
  opacity: 0;
}
.color-picker .material-symbols-outlined {
  font-size: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Add button */
.btn--add {
  width: 100%;
  height: 44px;
  background: transparent;
  border: 2px dashed var(--border-strong);
  color: var(--text-muted);
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: border-color .2s ease, color .2s ease, background-color .2s ease;
}
.btn--add:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}

/* Mobile: stack actions */
@media (max-width: 480px) {
  .link-row {
    grid-template-columns: 44px 1fr;
    grid-template-areas:
      "preview inputs"
      "actions actions";
  }
  .link-row__preview { grid-area: preview; }
  .link-row__inputs { grid-area: inputs; }
  .link-row__actions {
    grid-area: actions;
    justify-content: flex-end;
    padding-top: 4px;
    border-top: 1px solid var(--border);
    margin-top: 2px;
  }
  .link-row__move { flex-direction: row; }
}

/* ============================================
   Modal (Icon Picker)
   ============================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: modalFadeIn .15s ease-out;
}
.modal[hidden] { display: none; }

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(4px);
}

.modal__panel {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPanelIn .2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPanelIn {
  from { transform: translateY(20px) scale(.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal__title {
  margin: 0;
  font-family: 'Manrope', 'Noto Sans Thai', sans-serif;
  font-size: 16px;
  font-weight: 700;
}

.modal__toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 6px 12px 6px 36px;
  transition: border-color .15s ease, box-shadow .2s ease;
}
.search-input:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}
.search-input .material-symbols-outlined {
  position: absolute;
  left: 10px;
  color: var(--text-soft);
  font-size: 20px;
}
.search-input input {
  width: 100%;
  border: none;
  background: transparent;
  font: inherit;
  color: var(--text);
  outline: none;
  padding: 4px 0;
}

.btn--ghost {
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0 14px;
}
.btn--ghost:hover { background: var(--surface-3); }

/* Icon Grid */
.icon-grid {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 16px;
}

.icon-group + .icon-group { margin-top: 18px; }

.icon-group__title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.icon-group__items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 6px;
}

.icon-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text);
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .12s ease;
  text-align: center;
}
.icon-cell:hover {
  background: var(--surface-3);
  border-color: var(--border);
}
.icon-cell:active { transform: scale(.96); }
.icon-cell.is-selected {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  border-color: var(--primary);
  color: var(--primary);
}
.icon-cell .material-symbols-outlined { font-size: 24px; }
.icon-cell__label {
  font-size: 10px;
  color: var(--text-soft);
  line-height: 1.2;
  word-break: break-word;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--text-soft);
  font-size: 14px;
}

body.is-modal-open { overflow: hidden; }

/* Upload section (inside icon picker modal) */
.upload-section {
  padding: 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.upload-divider {
  position: relative;
  text-align: center;
  margin: 14px 0;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.upload-divider span {
  background: var(--surface-2);
  padding: 0 12px;
  position: relative;
  z-index: 1;
}
.upload-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border-strong);
}
.upload-divider--solid {
  margin: 0;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.upload-divider--solid span { background: var(--surface); }

.url-input-row {
  display: flex;
  gap: 8px;
}
.url-input-row .form-input { flex: 1; }

.btn--sm {
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
}

/* QR Modal */
.modal__panel--qr { max-width: 380px; }

.qr-display {
  padding: 24px 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.qr-canvas-wrap {
  padding: 14px;
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .12);
  border: 1px solid var(--border);
}
.qr-canvas-wrap canvas,
.qr-canvas-wrap img {
  display: block;
  width: 240px;
  height: 240px;
  object-fit: contain;
}

.qr-url {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  word-break: break-all;
  margin: 0;
  max-width: 100%;
  line-height: 1.5;
  padding: 0 4px;
}

.qr-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 20px 20px;
}
.qr-actions .btn {
  height: 42px;
  padding: 0 12px;
}

/* Password Modal & Input */
.modal__panel--pw { max-width: 380px; }

.modal__title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pw-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pw-input {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 6px 0 12px;
  transition: border-color .15s ease, box-shadow .2s ease;
}
.pw-input:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}
.pw-input > .material-symbols-outlined {
  color: var(--text-soft);
  font-size: 20px;
  flex-shrink: 0;
}
.pw-input input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font: inherit;
  color: var(--text);
  outline: none;
  padding: 11px 4px;
  letter-spacing: 0.12em;
}
.pw-input .icon-btn { color: var(--text-soft); }
.pw-input .icon-btn:hover { color: var(--text); }

.pw-error {
  color: var(--danger);
  font-size: 13px;
  margin: 0;
  padding-left: 4px;
}

.pw-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
  margin-top: 4px;
}
.pw-actions .btn { width: 100%; }

.form-hint {
  margin: 6px 4px 0;
  font-size: 12px;
  color: var(--text-soft);
}
.form-hint--warn {
  color: var(--danger);
  opacity: 0.8;
  margin-top: 12px;
  text-align: center;
}

/* QR section in settings */
.qr-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.qr-section-head .section-title { margin: 0; }

.qr-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.qr-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color .15s ease, transform .12s ease;
}
.qr-list-item:hover { border-color: var(--border-strong); }

.qr-list-item__thumb {
  width: 72px;
  height: 72px;
  background: #fff;
  border-radius: 10px;
  padding: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
}
.qr-list-item__thumb canvas,
.qr-list-item__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-list-item__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.qr-list-item__name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.qr-list-item__url {
  font-size: 11px;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn--filled {
  background: var(--primary);
  color: #fff;
}
.icon-btn--filled:hover { background: var(--primary-600); }

@media (max-width: 480px) {
  .modal { padding: 0; align-items: flex-end; }
  .modal__panel {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .icon-group__items { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
}

/* ============================================
   Reduced motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
