/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.05s, background 0.15s, box-shadow 0.15s, border-color 0.15s, color 0.15s;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn--primary {
  background: var(--brand-gradient);
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 102, 171, 0.22);
}
.btn--primary:hover { box-shadow: 0 8px 24px rgba(0, 102, 171, 0.32); }

.btn--outline {
  background: var(--bg-card);
  border-color: var(--border-strong);
  color: var(--brand-deep);
}
.btn--outline:hover { background: var(--bg-soft); }
[data-theme="dark"] .btn--outline { color: var(--brand-cyan); }

.btn--ghost {
  background: transparent;
  color: var(--brand-deep);
}
.btn--ghost:hover { background: var(--bg-soft); }

.btn--danger {
  background: var(--bg-card);
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.3);
}
.btn--danger:hover { background: rgba(220, 38, 38, 0.06); }

.btn--lg { padding: 14px 26px; font-size: 1.05rem; border-radius: 14px; }
.btn--sm { padding: 6px 12px; font-size: 0.85rem; }
.btn--block { width: 100%; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field__label { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.field__hint { font-size: 0.82rem; color: var(--text-muted); }

.input,
.textarea,
.select {
  font: inherit;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--brand-mid);
  box-shadow: 0 0 0 4px rgba(57, 164, 220, 0.16);
}
.textarea { resize: vertical; min-height: 140px; font-family: var(--font-ui); }

.input--inline { width: auto; min-width: 80px; }

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 0.95rem;
}
.checkbox input { width: 18px; height: 18px; accent-color: var(--brand-deep); }

.field-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

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

.card--accent {
  border-top: 4px solid var(--brand-cyan);
}

.tool-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-top: 24px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  position: relative;
  overflow: hidden;
}
.tool-card::after {
  content: "";
  position: absolute;
  inset: auto -40% -50% auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(18, 195, 244, 0.18), transparent 70%);
  pointer-events: none;
}
.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand-mid);
  text-decoration: none;
}
.tool-card__icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--brand-gradient);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.tool-card__title { margin: 0; font-size: 1.15rem; }
.tool-card__desc { color: var(--text-muted); font-size: 0.95rem; margin: 0; }
.tool-card__cta { margin-top: auto; font-weight: 600; color: var(--brand-deep); font-size: 0.9rem; }

/* Tag / chip */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

/* Layout for tool pages */
.tool-layout {
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr;
}
@media (min-width: 920px) {
  .tool-layout {
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: start;
  }
  .tool-layout--reverse { grid-template-columns: 360px minmax(0, 1fr); }
}

/* Result list */
.result-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}
.result-list li {
  padding: 8px 14px;
  background: var(--brand-gradient);
  color: #fff;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 1rem;
}
.result-list--mono li { font-family: 'SFMono-Regular', Menlo, Consolas, monospace; }

/* Toast */
.toast-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 220px;
  max-width: 360px;
  background: #0b2333;
  color: #ffffff;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.95rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}
[data-theme="dark"] .toast { background: #1e3a52; }
.toast.is-show { opacity: 1; transform: translateY(0); }
.toast--success { background: var(--success); }
.toast--error { background: var(--danger); }

/* Modal */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-root.is-open { display: flex; }
.modal-root__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 35, 51, 0.55);
  backdrop-filter: blur(2px);
}
.modal {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: modalIn 0.25s ease-out;
  color: var(--text);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}
.modal__title { margin: 0 0 8px; }
.modal__body { color: var(--text-muted); margin-bottom: 20px; }
.modal__result {
  font-family: var(--font-heading);
  font-size: clamp(1.5rem, 3vw + 1rem, 2.4rem);
  font-weight: 700;
  color: var(--brand-deep);
  margin: 12px 0 20px;
  word-break: break-word;
}
.modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.table th,
.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.table th {
  background: var(--bg-soft);
  font-weight: 600;
  color: var(--text);
}
.table tbody tr:hover { background: var(--bg-soft); }
.table .row-remove {
  background: transparent;
  border: 0;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

/* Fullscreen */
.fullscreen-host { position: relative; }

.fullscreen-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.fullscreen-btn:hover { color: var(--brand-deep); border-color: var(--border-strong); }
.fullscreen-btn svg { width: 18px; height: 18px; }

/* Inline variant — placed inside an existing toolbar, no absolute positioning */
.fullscreen-btn--inline { position: static; }
.fullscreen-host:fullscreen .fullscreen-btn--inline,
.fullscreen-host:-webkit-full-screen .fullscreen-btn--inline {
  position: fixed;
  top: 20px;
  right: 20px;
}
.fullscreen-btn .fs-exit { display: none; }
.fullscreen-host.is-fullscreen .fullscreen-btn .fs-enter { display: none; }
.fullscreen-host.is-fullscreen .fullscreen-btn .fs-exit  { display: block; }

/* When card itself enters fullscreen */
.fullscreen-host:fullscreen,
.fullscreen-host:-webkit-full-screen {
  background: var(--bg);
  width: 100vw;
  height: 100vh;
  padding: clamp(20px, 4vw, 48px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: auto;
  border-radius: 0;
  border: 0;
  box-shadow: none;
}
.fullscreen-host:fullscreen .fullscreen-btn,
.fullscreen-host:-webkit-full-screen .fullscreen-btn {
  position: fixed;
  top: 20px;
  right: 20px;
}

/* Share modal */
.share-modal { z-index: 1100; }
.share-modal .modal { max-width: 380px; }
.share-modal__close {
  position: absolute;
  top: 12px; right: 12px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 0;
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.share-modal__close:hover { background: var(--border); }
.share-modal__qr {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 12px;
  margin: 0 auto 12px;
  width: max-content;
  border: 1px solid var(--border);
}
.share-modal__qr svg { display: block; }
.share-modal__link {
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 0.82rem;
  word-break: break-all;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-muted);
}
