/* BLOX O₂ - mobile styles
 *
 * Built on the Quasii Chrome extension's design system (sidepanel.css): same
 * variable names, palette, components and dark theme, so the two read as one
 * product. The extension draws at a compact desktop scale (13px body, 24px
 * hit targets); a phone needs the opposite, so the radii, spacing and type
 * scale below are stepped up for touch while every colour stays the same.
 */

@property --send-btn-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

:root {
  /* Brand palette, unchanged from the extension */
  --primary-color: #baadeb;
  --primary-dark: #d0b8e8;
  --primary-ink: #6d5b9e;
  --danger-color: #ef4444;
  --success-color: #6b9e7a;

  --bg-primary: #ffffff;
  --bg-secondary: #faf9fa;
  --bg-tertiary: #f3f4f6;
  --bg-user: #f5f2fb;

  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;

  --border-light: #e5e7eb;
  --border-medium: #d1d5db;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 10px -2px rgba(0, 0, 0, 0.12);
  --focus-ring: 0 0 0 3px rgba(186, 173, 235, 0.25);

  /* The rotating pastel ring shared by the logomark and the primary buttons */
  --brand-ring: #97e1ef, #b2f7ef, #eff7f6, #f7d6e0, #f2b5d4, #96e1ef;

  /* Touch scale: the extension's radii and spacing stepped up */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;

  --font-body: system-ui, -apple-system, 'Segoe UI', 'Helvetica Neue', sans-serif;
  --font-brand: 'DM Sans', var(--font-body);
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, monospace;

  /* Same roles as the extension; only the primitives are larger */
  --font-size-body: 15px;
  /* 16px on anything typed into, or iOS zooms the page on focus */
  --font-size-control: 16px;
  --font-size-label: 13px;
  --font-size-meta: 11px;
  --font-size-title: 17px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Status messages */
  --success-bg: #ecf6ef;
  --success-text: #3f7350;
  --success-border: #cfe6d6;
  --error-bg: #fdecec;
  --error-text: #b42318;
  --error-border: #f8cfcf;
  --info-bg: var(--bg-user);
  --info-text: var(--primary-ink);
  --info-border: #e2dbf7;
}

* {
  box-sizing: border-box;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--font-size-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button,
input {
  font-family: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.screen {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ==================== AUTH SCREEN (BLOX O₂ brand) ==================== */

.login-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  padding: max(32px, var(--safe-top)) 20px max(24px, var(--safe-bottom));
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--bg-primary);
}

.login-form-wrapper {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  animation: login-rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

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

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 28px;
}

.login-icon {
  width: 104px;
  height: 104px;
  display: block;
  margin-bottom: 24px;
  /* Same lavender shadow as .login-btn; drop-shadow follows the icon's rounded shape */
  filter: drop-shadow(0 4px 10px rgba(174, 161, 213, 0.35));
}

.login-title {
  margin: 0 0 12px;
  color: var(--text-primary);
  font-family: var(--font-brand);
  font-size: 44px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.login-title sub {
  position: relative;
  top: 0.2em;
  margin-left: 1px;
  font-size: 0.5em;
  vertical-align: baseline;
  background: linear-gradient(135deg, #4fc6de, #d77fb0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.login-subtitle {
  max-width: 300px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.45;
  text-wrap: balance;
}

.login-card {
  padding: 24px 20px 20px;
  border: 1px solid var(--border-light);
  border-radius: 24px;
  background: var(--bg-primary);
  box-shadow:
    0 1px 2px rgba(29, 29, 31, 0.04),
    0 12px 40px rgba(29, 29, 31, 0.08);
}

.login-form-label {
  display: block;
  margin-bottom: var(--spacing-sm);
  color: var(--text-primary);
  font-size: var(--font-size-label);
  font-weight: 600;
}

.login-form-input {
  width: 100%;
  height: 52px;
  padding: 0 var(--spacing-lg);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: var(--font-size-control);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.login-form-input:focus {
  outline: none;
  border-color: var(--primary-color);
  background: var(--bg-primary);
  box-shadow: var(--focus-ring);
}

.login-form-input::placeholder {
  color: var(--text-tertiary);
}

/* Neon button: light grey core with a rotating pastel conic-gradient border.
   The border is transparent; the conic layer (border-box) shows through it. */
@keyframes send-btn-rotate {
  to { --send-btn-angle: 360deg; }
}

.login-btn {
  --btn-ring-mid: #b2f7ef, #eff7f6, #f7d6e0, #f2b5d4;
  --btn-ring: #97e1ef, var(--btn-ring-mid), #96e1ef;
  --btn-fill: #f7f7f7;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  width: 100%;
  height: 54px;
  margin-top: var(--spacing-lg);
  border: 4px solid transparent;
  border-radius: 16px;
  background:
    linear-gradient(var(--btn-fill), var(--btn-fill)) padding-box,
    conic-gradient(from var(--send-btn-angle), var(--btn-ring)) border-box;
  color: #1d1d1f;
  font-family: var(--font-brand);
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(174, 161, 213, 0.3);
  transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.1s cubic-bezier(0.4, 0, 0.2, 1);
  animation: send-btn-rotate 8s linear infinite;
}

.login-btn:hover {
  --btn-ring: #7bdff2, var(--btn-ring-mid), #7bdff2;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(174, 161, 213, 0.4);
  animation-duration: 2.667s;
}

.login-btn:active {
  transform: none;
  box-shadow: 0 2px 8px rgba(174, 161, 213, 0.3);
}

.login-btn:focus-visible {
  outline: 2px solid #4b4f5c;
  outline-offset: 2px;
}

.login-btn:disabled {
  opacity: 0.55;
  animation: none;
  transform: none;
  cursor: not-allowed;
}

.login-btn svg {
  width: 18px;
  height: 18px;
}

.login-forgot-link {
  margin-top: var(--spacing-lg);
  text-align: center;
}

.login-link {
  color: var(--primary-ink);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

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

.login-footer {
  margin-top: 28px;
  color: var(--text-tertiary);
  font-size: var(--font-size-label);
  text-align: center;
}

/* ==================== STATUS MESSAGES ==================== */

.login-status,
.status {
  width: 100%;
  margin-bottom: var(--spacing-lg);
  padding: var(--spacing-md) var(--spacing-lg);
  border: 1px solid;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

.login-status.success,
.status.success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.login-status.error,
.status.error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}

.login-status.info,
.status.info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-text);
}

/* ==================== MAIN SCREEN ==================== */

/* Header, list and footer stack in one column; only the list scrolls. */
.app-header {
  flex-shrink: 0;
  padding-top: var(--safe-top);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-primary);
}

/* Search, as the extension's .library-search: icon inside a tinted field */
.search-box {
  position: relative;
  padding: var(--spacing-md) var(--spacing-lg) var(--spacing-sm);
}

.search-icon {
  position: absolute;
  top: calc(50% + 2px);
  left: calc(var(--spacing-lg) + 12px);
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  pointer-events: none;
  transform: translateY(-50%);
}

.search-box input {
  width: 100%;
  height: 44px;
  padding: 0 44px 0 40px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: var(--font-size-control);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary-color);
  background: var(--bg-primary);
  box-shadow: var(--focus-ring);
}

.search-box input::placeholder {
  color: var(--text-tertiary);
}

.clear-btn {
  position: absolute;
  top: calc(50% + 2px);
  right: calc(var(--spacing-lg) + 6px);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transform: translateY(-50%);
}

.clear-btn:active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.clear-btn svg {
  width: 16px;
  height: 16px;
}

/* Tabs, as the extension's header strip: underline indicator in the accent */
.tab-nav {
  display: flex;
  gap: 1px;
  padding: 0 var(--spacing-sm);
}

.tab-btn {
  position: relative;
  flex: 1;
  height: 44px;
  border: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--font-size-label);
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.tab-btn::after {
  content: '';
  position: absolute;
  inset: auto var(--spacing-md) 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
  transition: background 0.15s ease;
}

.tab-btn:active {
  background: var(--bg-secondary);
}

.tab-btn:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: -2px;
}

.tab-btn.active {
  color: var(--text-primary);
}

.tab-btn.active::after {
  background: var(--primary-color);
}

/* Tag filters. A sideways scroller here rather than the extension's wrap: on
   a phone a swipe is the expected gesture, and wrapping would push the list
   down by a row per handful of tags. */
.tag-filters {
  display: flex;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm) var(--spacing-lg);
  border-top: 1px solid var(--border-light);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tag-filters:empty {
  display: none;
}

.tag-filters::-webkit-scrollbar {
  display: none;
}

.filter-tag {
  flex-shrink: 0;
  height: 30px;
  padding: 0 var(--spacing-md);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: var(--font-size-label);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-tag:active {
  border-color: var(--border-medium);
  color: var(--text-primary);
}

/* "All" when selected; a selected tag carries its own colour inline */
.filter-tag.active {
  border-color: var(--primary-color);
  background: var(--bg-user);
  color: var(--primary-ink);
  font-weight: 600;
}

/* ==================== CONTENT AREA ==================== */

.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* Rows, as the extension's .item: flat, hairline-separated, accent edge */
.item {
  position: relative;
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--border-light);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
}

.item:active {
  background: var(--bg-secondary);
}

.item.holding {
  border-left-color: var(--primary-color);
  background: var(--bg-user);
}

.item.copied {
  animation: copy-flash 0.5s ease-out;
}

@keyframes copy-flash {
  from { background: rgba(186, 173, 235, 0.45); }
  to   { background: transparent; }
}

.item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--spacing-sm);
}

.item-title {
  color: var(--text-primary);
  font-size: var(--font-size-body);
  font-weight: 600;
  line-height: 1.3;
}

.item-pin {
  flex-shrink: 0;
  width: 13px;
  height: 13px;
  margin-top: 2px;
  fill: var(--border-medium);
}

.item-shortcut {
  display: inline-block;
  margin-top: var(--spacing-xs);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: var(--font-size-meta);
}

.item-preview {
  margin-top: var(--spacing-xs);
  color: var(--text-secondary);
  font-size: var(--font-size-label);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Inherits the preview colour so a list of links is not a wall of blue */
.item-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--border-medium);
  text-underline-offset: 2px;
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-xs);
  margin-top: 6px;
}

.tag {
  max-width: 160px;
  padding: 1px var(--spacing-sm);
  border: 1px solid;
  border-radius: 20px;
  font-size: var(--font-size-meta);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-variables {
  color: var(--text-tertiary);
  font-size: var(--font-size-meta);
  letter-spacing: 0.04em;
}

.empty-state {
  padding: 56px 24px;
  color: var(--text-tertiary);
  text-align: center;
}

.empty-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto var(--spacing-md);
  opacity: 0.5;
}

.empty-icon svg {
  width: 100%;
  height: 100%;
  stroke-width: 1.5;
}

.empty-text {
  color: var(--text-secondary);
  font-size: var(--font-size-body);
  font-weight: 600;
}

.empty-hint {
  margin-top: var(--spacing-xs);
  font-size: var(--font-size-label);
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-md);
  padding: 56px 24px;
  color: var(--text-tertiary);
  font-size: var(--font-size-label);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==================== FOOTER ==================== */

.app-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(56px + var(--safe-bottom));
  padding: 0 var(--spacing-sm) var(--safe-bottom);
  border-top: 1px solid var(--border-light);
  background: var(--bg-primary);
}

/* The extension's .icon-btn at touch size */
.footer-btn,
.back-btn,
.modal-close {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.footer-btn:active,
.back-btn:active,
.modal-close:active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.footer-btn svg,
.back-btn svg,
.modal-close svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.7;
}

.footer-btn.syncing svg {
  color: var(--primary-color);
  animation: spin 1s linear infinite;
}

.footer-info {
  color: var(--text-tertiary);
  font-size: var(--font-size-meta);
  text-align: center;
}

/* ==================== SETTINGS SCREEN ==================== */

.settings-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  min-height: calc(52px + var(--safe-top));
  padding: var(--safe-top) var(--spacing-sm) 0;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-primary);
}

.settings-header h2 {
  font-size: var(--font-size-title);
  font-weight: 600;
}

.settings-content {
  flex: 1;
  min-height: 0;
  padding: var(--spacing-lg);
  padding-bottom: calc(var(--spacing-lg) + var(--safe-bottom));
  overflow-y: auto;
}

/* Grouped rows in one bordered surface, like the extension's sheet */
.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  padding: var(--spacing-md) var(--spacing-lg);
  border: 1px solid var(--border-light);
  border-top-width: 0;
  background: var(--bg-primary);
}

/* First and last of the run; the status box and button around it are divs too,
   so :first-of-type would miss */
.setting-item:not(.setting-item + .setting-item) {
  border-top-width: 1px;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

.setting-item:not(:has(+ .setting-item)) {
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

.setting-label {
  color: var(--text-primary);
  font-size: var(--font-size-body);
}

.setting-value {
  color: var(--text-secondary);
  font-size: var(--font-size-body);
}

.app-version {
  margin-top: 40px;
  color: var(--text-tertiary);
  font-size: var(--font-size-label);
  text-align: center;
}

.app-version .powered-by {
  margin-top: 2px;
  font-size: var(--font-size-meta);
}

/* ==================== BUTTONS ==================== */

/* The extension's .library-btn: lavender core inside the rotating pastel ring */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  height: 48px;
  padding: 0 var(--spacing-lg);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  font-size: var(--font-size-body);
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-large {
  width: 100%;
  margin-top: var(--spacing-lg);
}

.btn-clipboard {
  background:
    linear-gradient(#baadeb, #baadeb) padding-box,
    conic-gradient(from var(--send-btn-angle), var(--brand-ring)) border-box;
  color: #fff;
  animation: send-btn-rotate 8s linear infinite;
}

.btn-clipboard:active {
  background:
    linear-gradient(#a897e3, #a897e3) padding-box,
    conic-gradient(from var(--send-btn-angle), var(--brand-ring)) border-box;
  animation-duration: 2.667s;
}

.btn-secondary {
  border: 1px solid var(--border-light);
  background: var(--bg-primary);
  color: var(--text-secondary);
}

.btn-secondary:active {
  border-color: var(--border-medium);
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Secondary surface, danger text: a way out, not an alarm */
.btn-danger {
  border: 1px solid var(--border-light);
  background: var(--bg-primary);
  color: var(--danger-color);
}

.btn-danger:active {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.06);
}

/* ==================== TOAST ==================== */

/* A card in the sheet's family rather than a dark slab, spanning the width so
   it does not re-wrap as the message changes */
.toast {
  position: fixed;
  left: var(--spacing-md);
  right: var(--spacing-md);
  bottom: calc(56px + var(--safe-bottom) + var(--spacing-md));
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.visible {
  opacity: 1;
  transform: none;
}

.toast svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--primary-color);
}

/* ==================== COPY HINT ==================== */

.copy-hint {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.92);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.copy-hint.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.copy-hint-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 20px 28px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
}

.copy-hint-content svg {
  width: 28px;
  height: 28px;
  color: var(--primary-color);
}

/* ==================== VARIABLE SHEET ==================== */

/* The extension's .sheet, docked to the bottom as a phone sheet */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.35);
  animation: fade-in 0.18s ease-out;
}

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

.modal-content {
  position: relative;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
  border: 1px solid var(--border-light);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  background: var(--bg-primary);
  box-shadow: var(--shadow-md);
  animation: slide-up 0.25s ease-out;
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  padding: var(--spacing-xs) var(--spacing-xs) var(--spacing-xs) var(--spacing-lg);
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  font-size: var(--font-size-title);
  font-weight: 600;
}

.modal-body {
  flex: 1;
  min-height: 0;
  padding: var(--spacing-lg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  flex-shrink: 0;
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--border-light);
}

.modal-footer .btn-secondary {
  flex: 0 0 auto;
}

.modal-footer .btn-clipboard {
  flex: 1;
}

.variable-group {
  margin-bottom: var(--spacing-lg);
}

.variable-group:last-child {
  margin-bottom: 0;
}

.variable-label {
  display: block;
  margin-bottom: var(--spacing-xs);
  color: var(--text-primary);
  font-size: var(--font-size-label);
  font-weight: 600;
}

.variable-description {
  margin-bottom: var(--spacing-xs);
  color: var(--text-secondary);
  font-size: var(--font-size-meta);
}

.variable-input {
  width: 100%;
  height: 46px;
  padding: 0 var(--spacing-md);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: var(--font-size-control);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.variable-input:focus {
  outline: none;
  border-color: var(--primary-color);
  background: var(--bg-primary);
  box-shadow: var(--focus-ring);
}

.variable-input::placeholder {
  color: var(--text-tertiary);
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 380px) {
  .login-title {
    font-size: 38px;
  }

  .login-icon {
    width: 88px;
    height: 88px;
  }
}

@media (max-width: 360px) {
  :root {
    --font-size-body: 14px;
    --font-size-label: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-form-wrapper,
  .login-btn,
  .btn-clipboard,
  .item.copied,
  .modal-backdrop,
  .modal-content {
    animation: none;
  }

  .tab-btn,
  .tab-btn::after,
  .toast,
  .copy-hint {
    transition: none;
  }
}

/* ==================== DARK THEME ==================== */

/* The extension's dark tokens */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #1f2023;
    --bg-secondary: #26272b;
    --bg-tertiary: #2f3035;
    --bg-user: #2c2838;

    --text-primary: #f3f4f6;
    --text-secondary: #a1a1aa;
    --text-tertiary: #7b7b85;

    --border-light: #35363c;
    --border-medium: #45464d;

    --primary-ink: #d6cbf5;

    --success-bg: rgba(107, 158, 122, 0.14);
    --success-text: #9fd1ad;
    --success-border: rgba(107, 158, 122, 0.35);
    --error-bg: rgba(239, 68, 68, 0.12);
    --error-text: #fca5a5;
    --error-border: rgba(239, 68, 68, 0.35);
    --info-border: #3b3550;
  }

  .modal-backdrop {
    background: rgba(0, 0, 0, 0.55);
  }

  /* Tag chips carry inline pastel colours from the shared palette */
  .tag,
  .filter-tag {
    filter: saturate(0.85);
  }

  .login-card {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  }

  .toast,
  .copy-hint-content {
    box-shadow: 0 6px 16px -4px rgba(0, 0, 0, 0.6);
  }
}
