:root {
  --bg: #050507;
  --bg-card: #0e0e12;
  --ink: #f0f0f2;
  --ink-muted: rgba(240, 240, 242, 0.45);
  --ink-faint: rgba(240, 240, 242, 0.22);
  --border: rgba(255, 255, 255, 0.09);
  --border-focus: rgba(255, 255, 255, 0.3);
  --accent: #9b8cff;
  --link: #74b9ff;
  --danger: #ff6b6b;
  --font-display: "Manrope", system-ui, -apple-system, sans-serif;
  --font-mono: "DM Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-size: 17px;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100vw;
  min-height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
  border: none;
  background: transparent;
}

button {
  cursor: pointer;
}

/* Zen Layout Container */
.zen-layout {
  width: 100%;
  max-width: 920px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 56px 24px 40px 24px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* Header */
.zen-header {
  display: flex;
  justify-content: center;
  align-items: baseline;
  margin-bottom: 2.2rem;
  user-select: none;
  width: 100%;
  max-width: 100%;
}

.brand-wrapper {
  display: inline-flex;
  align-items: baseline;
  max-width: 100%;
}

.brand-name {
  font-size: clamp(2.4rem, 8vw, 4.6rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  color: #ffffff;
  line-height: 1;
  text-transform: lowercase;
}

.brand-qr {
  color: var(--accent);
}

.brand-tld {
  font-family: var(--font-mono);
  font-size: clamp(0.95rem, 3.2vw, 1.2rem);
  color: var(--ink-muted);
  margin-left: 6px;
  font-weight: 400;
}

/* Single Line Input */
.zen-input-section {
  width: 100%;
  margin-bottom: 2.4rem;
}

.zen-input-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.zen-input-row {
  width: 100%;
  display: flex;
  align-items: center;
  min-height: 64px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 6px 24px -2px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  padding: 6px 10px 6px 8px;
}

.zen-input-row:focus-within {
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.05), 0 10px 36px -4px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.zen-url-input {
  flex: 1;
  min-width: 0;
  padding: 12px 18px;
  font-size: 1.22rem;
  font-weight: 500;
  color: #ffffff;
  outline: none;
  font-family: inherit;
  letter-spacing: -0.01em;
}

.zen-url-input::placeholder {
  color: var(--ink-faint);
  font-weight: 400;
  transition: color 0.15s ease;
}

.zen-input-row:focus-within .zen-url-input::placeholder {
  color: rgba(240, 240, 242, 0.16);
}

.zen-input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* In-Bar Icon Buttons: Action (Paste/Create) and Clear */
.zen-bar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  color: var(--ink-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
  padding: 0;
  flex-shrink: 0;
}

.zen-bar-icon-btn svg {
  width: 22px;
  height: 22px;
}

.zen-bar-icon-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.zen-bar-icon-btn:active {
  transform: scale(0.92);
}

/* Active create state (valid URL typed/pasted) */
.zen-bar-icon-btn.zen-create-active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.zen-bar-icon-btn.zen-create-active:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.2);
}

/* Disabled create state (invalid URL) - preserves hueco with disabled styling & tooltip */
.zen-bar-icon-btn.is-disabled {
  opacity: 0.22;
  cursor: not-allowed;
  pointer-events: auto; /* Ensures title tooltip appears on hover */
}

.zen-bar-icon-btn.is-disabled:hover {
  color: var(--ink-muted);
  background: transparent;
}

.zen-bar-icon-btn.is-disabled:active {
  transform: none;
}

.zen-submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  min-height: 46px;
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 1.05rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
}

.zen-submit-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.zen-submit-btn.visible {
  display: inline-flex !important;
}

/* Links List Section */
.zen-list-section {
  flex: 1;
  width: 100%;
}

.zen-links-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.zen-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 12px;
  border-bottom: 1px solid var(--border);
  gap: 18px;
  transition: opacity 0.2s ease, background 0.15s ease, border-color 0.15s ease;
}

.zen-link-row:hover {
  background: rgba(255, 255, 255, 0.02);
}

.zen-link-row.is-dimmed {
  opacity: 0.48;
}

.zen-link-row.is-dimmed:hover {
  opacity: 0.88;
}

.zen-link-row.is-update-target {
  background: transparent;
  opacity: 1 !important;
}

/* Inline Update Button on Target Link - Icon Only, Transparent, No Violet */
.zen-row-update-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 6px;
  color: var(--ink-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s ease, background 0.15s ease, transform 0.25s ease;
  animation: updateBtnPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.zen-row-update-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  transition: stroke 0.15s ease, transform 0.25s ease;
}

.zen-row-update-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  transform: rotate(180deg);
}

.zen-row-update-btn:active {
  transform: rotate(180deg) scale(0.9);
}

@keyframes updateBtnPop {
  from {
    opacity: 0;
    transform: scale(0.75);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.zen-link-row.highlight-flash {
  animation: rowFlash 1.2s ease-out;
}

@keyframes rowFlash {
  0% {
    background: rgba(155, 140, 255, 0.2);
  }
  100% {
    background: transparent;
  }
}

.zen-row-left {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  margin-right: 16px;
  gap: 10px;
}

.zen-target-badge {
  display: none !important;
}

.zen-target-left {
  font-family: var(--font-mono);
  font-size: 1.12rem;
  color: var(--ink-muted);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
  max-width: 100%;
  transition: color 0.12s;
}

.zen-target-left:hover {
  color: #ffffff;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.zen-row-right {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-shrink: 0;
}

.zen-short-url {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 500;
  color: rgba(240, 240, 242, 0.88);
  text-decoration: none;
  white-space: nowrap;
  user-select: all;
  display: inline-flex;
  align-items: baseline;
  transition: color 0.12s;
}

.zen-short-url:hover {
  color: #ffffff;
}

.zen-part-bold {
  font-weight: 500;
  color: inherit;
}

.zen-part-dim {
  font-weight: 500;
  color: inherit;
}

.zen-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Action Icon Buttons - Generous 44px Touch Targets */
.action-icon-btn {
  color: rgba(240, 240, 242, 0.45);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}

.action-icon-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.action-icon-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* Visit counter button with eye (no background) */
.zen-visits-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: rgba(240, 240, 242, 0.5);
  background: transparent;
  min-height: 44px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}

.zen-visits-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.zen-visits-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

/* Three dots button */
.zen-dots-btn {
  color: rgba(240, 240, 242, 0.45);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}

.zen-dots-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

.zen-dots-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

/* Empty state */
.zen-empty {
  padding: 64px 0;
  text-align: center;
  color: var(--ink-faint);
  font-size: 1.15rem;
}

/* Footer */
.zen-footer {
  margin-top: auto;
  padding-top: 40px;
  display: flex;
  justify-content: center;
}

.zen-footer-link {
  font-size: 0.95rem;
  color: var(--ink-faint);
  padding: 10px 18px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}

.zen-footer-link:hover {
  color: var(--ink-muted);
  background: rgba(255, 255, 255, 0.04);
}

/* Generic Zen Buttons - Generous, Touch-Friendly */
.zen-btn {
  background: #ffffff;
  color: #050507;
  font-weight: 600;
  font-size: 1rem;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 8px;
  transition: opacity 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.zen-btn:hover {
  opacity: 0.9;
}

.zen-btn.small {
  min-height: 38px;
  padding: 8px 16px;
  font-size: 0.92rem;
  border-radius: 7px;
}

.zen-btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 1rem;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 8px;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.zen-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

.zen-btn-ghost.small {
  min-height: 38px;
  padding: 8px 16px;
  font-size: 0.92rem;
  border-radius: 7px;
}

.zen-btn-danger {
  color: var(--danger);
  font-size: 0.95rem;
  min-height: 42px;
  padding: 8px 16px;
  border-radius: 8px;
  transition: background 0.15s;
}

.zen-btn-danger:hover {
  background: rgba(255, 107, 107, 0.12);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card.zen-modal {
  width: 100%;
  max-width: 560px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px 30px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.9);
}

.zen-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.zen-modal-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
  color: #fff;
}

.zen-modal-sub {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 500;
  color: rgba(240, 240, 242, 0.82);
  margin: 6px 0 20px 0;
}

.icon-btn.close-btn {
  color: var(--ink-muted);
  font-size: 1.3rem;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}

.icon-btn.close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

/* Zen Edit Modal */
.zen-edit-modal {
  max-width: 600px !important;
}

.zen-edit-form {
  margin-bottom: 22px;
}

/* Destination History */
.zen-history-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 14px;
}

.zen-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.zen-history-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.zen-history-badge {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  color: var(--ink-muted);
}

.zen-history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.zen-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  transition: background 0.12s;
}

.zen-history-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.zen-history-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.zen-history-url {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zen-history-time {
  font-size: 0.82rem;
  color: var(--ink-faint);
  margin-top: 3px;
}

.zen-history-empty {
  font-size: 0.92rem;
  color: var(--ink-faint);
  font-style: italic;
  padding: 14px 0;
  text-align: center;
}

.zen-link-danger-btn {
  font-size: 0.92rem;
  color: rgba(255, 107, 107, 0.8);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px 14px;
  min-height: 40px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.zen-link-danger-btn:hover {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
}

/* Analytics Zen Modal */
.analytics-zen-modal {
  max-width: 760px !important;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.pro-tag {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.zen-dest-sub {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--ink-faint);
  display: block;
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zen-period-pills {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 3px;
}

.period-pill {
  font-size: 0.88rem;
  color: var(--ink-muted);
  padding: 6px 14px;
  border-radius: 6px;
  min-height: 36px;
}

.period-pill.active {
  background: #ffffff;
  color: #050507;
  font-weight: 600;
}

.analytics-zen-body {
  overflow-y: auto;
  padding: 18px 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.zen-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.zen-kpi {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
}

.zen-kpi-label {
  font-size: 0.78rem;
  color: var(--ink-muted);
  text-transform: uppercase;
}

.zen-kpi-num {
  font-size: 1.65rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}

.zen-kpi-tiny {
  font-size: 0.78rem;
  color: var(--accent);
}

.zen-kpi-text {
  font-size: 1.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zen-chart-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.zen-chart-hint {
  font-size: 0.85rem;
  color: var(--ink-muted);
  display: block;
  margin-bottom: 6px;
}

.zen-breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.zen-breakdown-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.breakdown-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  display: block;
  margin-bottom: 10px;
}

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.zen-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: auto;
}

/* QR Box */
.zen-qr-box {
  width: 240px;
  height: 240px;
  background: #ffffff;
  border-radius: 12px;
  padding: 12px;
  margin: 18px auto;
}

.zen-qr-box svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #18181c;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.18s ease;
  z-index: 200;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 640px) {
  html {
    font-size: 15.5px;
  }

  .zen-layout {
    padding: 24px 14px 20px 14px;
    max-width: 100%;
    overflow-x: hidden;
  }

  .zen-header {
    margin-bottom: 1.6rem;
  }

  .zen-input-section {
    margin-bottom: 1.8rem;
  }

  .zen-input-row {
    min-height: 56px;
    padding: 4px 6px 4px 6px;
    max-width: 100%;
    min-width: 0;
  }

  .zen-url-input {
    font-size: 1.08rem;
    padding: 8px 12px;
    min-width: 0;
  }

  .zen-bar-icon-btn {
    width: 42px;
    height: 42px;
  }

  .zen-bar-icon-btn svg {
    width: 20px;
    height: 20px;
  }

  .zen-list-section,
  .zen-links-list {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .zen-link-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 14px 4px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .zen-row-left {
    margin-right: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .zen-target-left {
    margin-right: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    font-size: 1.05rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .zen-row-right {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 10px;
  }

  .zen-short-url {
    font-size: 1.15rem;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    user-select: all;
  }

  .zen-row-actions {
    margin-left: auto;
    gap: 4px;
    flex-shrink: 0;
  }

  .action-icon-btn,
  .zen-dots-btn {
    width: 40px;
    height: 40px;
  }

  .action-icon-btn svg,
  .zen-dots-btn svg {
    width: 18px;
    height: 18px;
  }

  .zen-visits-btn {
    min-height: 40px;
    padding: 0 8px;
    font-size: 0.95rem;
    gap: 4px;
  }

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

  .zen-kpi-row,
  .zen-breakdown-grid {
    grid-template-columns: 1fr;
  }

  .modal-card.zen-modal {
    padding: 20px 16px;
    border-radius: 14px;
    max-width: 100%;
    margin: 10px;
  }

  .zen-modal-title {
    font-size: 1.25rem;
  }

  .zen-modal-sub {
    font-size: 0.95rem;
  }

  .zen-qr-box {
    width: 200px;
    height: 200px;
  }
}
