@import url('https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,400..700&family=Roboto:wght@400;500;700&display=swap');

/* ---------------------------------------------------------------------
   Material 3 Expressive — pink dynamic-color scheme
   Roles follow the M3 color system (primary / secondary / tertiary,
   each with an "on-" pair and a tonal container pair) so light and dark
   read as one coherent theme rather than an inverted copy.
   --------------------------------------------------------------------- */
:root {
  color-scheme: light;

  --md-primary: #B3264D;
  --md-on-primary: #FFFFFF;
  --md-primary-container: #FFD9E1;
  --md-on-primary-container: #3F0018;

  --md-secondary: #75565C;
  --md-on-secondary: #FFFFFF;
  --md-secondary-container: #FFD9E1;
  --md-on-secondary-container: #2B151A;

  --md-tertiary: #7C5635;
  --md-on-tertiary: #FFFFFF;
  --md-tertiary-container: #FFDCC1;
  --md-on-tertiary-container: #2E1500;

  --md-surface: #FFF8F7;
  --md-surface-dim: #E8D6D7;
  --md-surface-bright: #FFF8F7;
  --md-surface-container-lowest: #FFFFFF;
  --md-surface-container-low: #FFF1F0;
  --md-surface-container: #FCEAE9;
  --md-surface-container-high: #F7E4E4;
  --md-surface-container-highest: #F1DFDE;
  --md-on-surface: #22191A;
  --md-on-surface-variant: #524347;
  --md-outline: #857276;
  --md-outline-variant: #D7C1C5;
  --md-background: #FFF8F7;
  --md-on-background: #22191A;

  --md-error: #BA1A1A;
  --md-on-error: #FFFFFF;
  --md-error-container: #FFDAD6;
  --md-on-error-container: #410002;

  --md-success: #2E6E3E;

  --md-shadow: 220 20 20;

  /* M3 shape scale — expressive leans larger and rounder */
  --shape-xs: 8px;
  --shape-sm: 12px;
  --shape-md: 16px;
  --shape-lg: 24px;
  --shape-xl: 28px;
  --shape-full: 999px;

  /* M3 emphasized easing */
  --ease-emphasized: cubic-bezier(0.2, 0, 0, 1);
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --md-primary: #FFB1C2;
    --md-on-primary: #660026;
    --md-primary-container: #8C0038;
    --md-on-primary-container: #FFD9E1;

    --md-secondary: #E3BDC3;
    --md-on-secondary: #422931;
    --md-secondary-container: #5B3F46;
    --md-on-secondary-container: #FFD9E1;

    --md-tertiary: #EFBD94;
    --md-on-tertiary: #48290C;
    --md-tertiary-container: #613F20;
    --md-on-tertiary-container: #FFDCC1;

    --md-surface: #1B1314;
    --md-surface-dim: #1B1314;
    --md-surface-bright: #423739;
    --md-surface-container-lowest: #150E0F;
    --md-surface-container-low: #22191A;
    --md-surface-container: #271D1E;
    --md-surface-container-high: #322829;
    --md-surface-container-highest: #3D3233;
    --md-on-surface: #F0DEDF;
    --md-on-surface-variant: #D6C1C5;
    --md-outline: #9F8C90;
    --md-outline-variant: #524347;
    --md-background: #1B1314;
    --md-on-background: #F0DEDF;

    --md-error: #FFB4AB;
    --md-on-error: #690005;
    --md-error-container: #93000A;
    --md-on-error-container: #FFDAD6;

    --md-success: #8FDB9C;

    --md-shadow: 0 0 0;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--md-background);
  color: var(--md-on-background);
  font-family: 'Roboto', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 100% -10%, color-mix(in srgb, var(--md-primary-container) 55%, transparent), transparent 45%),
    radial-gradient(circle at -10% 110%, color-mix(in srgb, var(--md-tertiary-container) 35%, transparent), transparent 40%);
  background-attachment: fixed;
}

h1, h2, h3, .display {
  font-family: 'Roboto Flex', 'Roboto', system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

a { color: var(--md-primary); }

button { font-family: inherit; }

/* ---------- Signature mark: two rounded links mid-morph into an arrow ---------- */
.mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.mark svg { width: 100%; height: 100%; }
.mark .link-a { fill: var(--md-primary); transition: transform .5s var(--ease-emphasized); transform-origin: 50% 50%; }
.mark .link-b { fill: var(--md-tertiary); transition: transform .5s var(--ease-emphasized); transform-origin: 50% 50%; }
.mark:hover .link-a { transform: translate(-1.5px, -1.5px) rotate(-8deg); }
.mark:hover .link-b { transform: translate(1.5px, 1.5px) rotate(-8deg); }

/* ---------------------------------------------------------------------- */
/* Layout shells                                                          */
/* ---------------------------------------------------------------------- */
.center-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(16px);
  background: color-mix(in srgb, var(--md-surface) 82%, transparent);
  border-bottom: 1px solid var(--md-outline-variant);
}
.top-bar h1 { font-size: 22px; }
.top-bar .domain-chip {
  font-family: 'Roboto Mono', monospace;
  font-size: 13px;
  color: var(--md-on-secondary-container);
  background: var(--md-secondary-container);
  padding: 4px 12px;
  border-radius: var(--shape-full);
}
.top-bar .spacer { flex: 1; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: var(--shape-full);
  border: none;
  background: transparent;
  color: var(--md-on-surface-variant);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .2s var(--ease-standard);
}
.icon-btn:hover { background: color-mix(in srgb, var(--md-on-surface) 8%, transparent); }
.icon-btn:focus-visible { outline: 2px solid var(--md-primary); outline-offset: 2px; }

main.content {
  flex: 1;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 24px 120px;
}

/* ---------------------------------------------------------------------- */
/* Card / surfaces                                                        */
/* ---------------------------------------------------------------------- */
.surface-card {
  background: var(--md-surface-container-low);
  border-radius: var(--shape-xl);
  box-shadow: 0 1px 3px rgba(var(--md-shadow), 0.12);
  padding: 32px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px 32px;
}
.login-card .mark { width: 56px; height: 56px; margin-bottom: 16px; }
.login-card h1 { font-size: 26px; margin-bottom: 4px; }
.login-card p.sub { color: var(--md-on-surface-variant); margin: 0 0 28px; font-size: 14px; }

/* ---------------------------------------------------------------------- */
/* Text fields (M3 filled style)                                          */
/* ---------------------------------------------------------------------- */
.field { margin-bottom: 20px; position: relative; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--md-on-surface-variant);
  margin-bottom: 6px;
}
.field .input-wrap { position: relative; }
.field input, .field textarea {
  width: 100%;
  font-size: 16px;
  font-family: inherit;
  color: var(--md-on-surface);
  background: var(--md-surface-container-high);
  border: none;
  border-bottom: 2px solid var(--md-outline);
  border-radius: var(--shape-xs) var(--shape-xs) 0 0;
  padding: 14px 16px;
  transition: background .2s var(--ease-standard), border-color .2s var(--ease-standard);
}
.field input::placeholder { color: var(--md-on-surface-variant); opacity: .7; }
.field input:focus, .field textarea:focus {
  outline: none;
  border-bottom-color: var(--md-primary);
  background: color-mix(in srgb, var(--md-primary-container) 30%, var(--md-surface-container-high));
}
.field.has-error input { border-bottom-color: var(--md-error); }
.field .prefix { color: var(--md-on-surface-variant); font-size: 15px; padding-left: 16px; align-self: center; white-space: nowrap; }
.field .input-row { display: flex; align-items: stretch; background: var(--md-surface-container-high); border-radius: var(--shape-xs) var(--shape-xs) 0 0; border-bottom: 2px solid var(--md-outline); }
.field .input-row:focus-within { border-bottom-color: var(--md-primary); background: color-mix(in srgb, var(--md-primary-container) 30%, var(--md-surface-container-high)); }
.field.has-error .input-row { border-bottom-color: var(--md-error); }
.field .input-row input { background: transparent; border: none; padding-left: 4px; }
.field .input-row input:focus { background: transparent; }

.field .helper {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin-top: 6px;
  min-height: 16px;
  color: var(--md-on-surface-variant);
}
.field .helper.error { color: var(--md-error); font-weight: 500; }
.field .helper.success { color: var(--md-success); font-weight: 500; }
.field .helper .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.field .helper .spinner {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin .6s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.checkbox-row {
  display: flex; align-items: center; gap: 10px;
  margin: -4px 0 20px;
  font-size: 14px;
  color: var(--md-on-surface-variant);
  cursor: pointer;
  user-select: none;
}
.checkbox-row input { accent-color: var(--md-primary); width: 18px; height: 18px; }

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none;
  border-radius: var(--shape-full);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .01em;
  padding: 12px 24px;
  cursor: pointer;
  transition: transform .15s var(--ease-emphasized), box-shadow .2s var(--ease-standard), background .2s var(--ease-standard);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-filled { background: var(--md-primary); color: var(--md-on-primary); }
.btn-filled:hover:not(:disabled) { box-shadow: 0 2px 8px rgba(var(--md-shadow), 0.24); }
.btn-tonal { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.btn-text { background: transparent; color: var(--md-primary); padding: 12px 16px; }
.btn-text:hover { background: color-mix(in srgb, var(--md-primary) 8%, transparent); }
.btn-danger-text { background: transparent; color: var(--md-error); padding: 12px 16px; }
.btn-danger-text:hover { background: color-mix(in srgb, var(--md-error) 8%, transparent); }
.btn-block { width: 100%; }

.fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  border: none;
  border-radius: var(--shape-lg);
  padding: 18px 26px 18px 20px;
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(var(--md-shadow), 0.28);
  cursor: pointer;
  transition: transform .2s var(--ease-emphasized), border-radius .2s var(--ease-emphasized);
  z-index: 20;
}
.fab:hover { transform: translateY(-2px) scale(1.02); border-radius: var(--shape-xl); }
.fab:active { transform: scale(0.96); }
.fab svg { width: 24px; height: 24px; }

/* ---------------------------------------------------------------------- */
/* Link list                                                               */
/* ---------------------------------------------------------------------- */
.list-head { display: flex; align-items: baseline; justify-content: space-between; margin: 8px 0 20px; }
.list-head h2 { font-size: 24px; }
.list-head .count { color: var(--md-on-surface-variant); font-size: 14px; }

.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--md-on-surface-variant);
}
.empty-state .mark { width: 64px; height: 64px; margin-bottom: 20px; opacity: .6; }
.empty-state h3 { font-size: 18px; color: var(--md-on-surface); margin-bottom: 8px; }

.link-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--md-surface-container-low);
  border-radius: var(--shape-lg);
  padding: 16px 16px 16px 20px;
  margin-bottom: 12px;
  transition: box-shadow .2s var(--ease-standard), background .2s var(--ease-standard);
}
.link-card:hover { box-shadow: 0 1px 4px rgba(var(--md-shadow), 0.16); background: var(--md-surface-container); }

.link-card .link-info { flex: 1; min-width: 0; }
.link-card .code-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.link-card .code {
  font-family: 'Roboto Mono', monospace;
  font-weight: 700;
  font-size: 15px;
  color: var(--md-primary);
}
.link-card .clicks {
  font-size: 11px;
  color: var(--md-on-tertiary-container);
  background: var(--md-tertiary-container);
  padding: 2px 8px;
  border-radius: var(--shape-full);
  flex-shrink: 0;
}
.link-card .target {
  font-size: 13px;
  color: var(--md-on-surface-variant);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-card .actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ---------------------------------------------------------------------- */
/* Dialog / sheet                                                          */
/* ---------------------------------------------------------------------- */
.scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease-standard);
}
.scrim.open { opacity: 1; pointer-events: auto; }

.dialog {
  width: 100%; max-width: 460px;
  background: var(--md-surface-container-high);
  border-radius: var(--shape-xl);
  padding: 28px;
  transform: translateY(16px) scale(.98);
  opacity: 0;
  transition: transform .3s var(--ease-emphasized), opacity .3s var(--ease-emphasized);
  max-height: 88vh;
  overflow-y: auto;
}
.scrim.open .dialog { transform: translateY(0) scale(1); opacity: 1; }
.dialog h2 { font-size: 20px; margin-bottom: 20px; }
.dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.top-error-banner {
  background: var(--md-error-container);
  color: var(--md-on-error-container);
  border-radius: var(--shape-md);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.top-error-banner.show { display: block; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  background: var(--md-on-surface);
  color: var(--md-surface);
  padding: 14px 20px;
  border-radius: var(--shape-sm);
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(var(--md-shadow), 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease-standard), transform .25s var(--ease-emphasized);
  z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.skeleton { color: var(--md-on-surface-variant); text-align: center; padding: 40px; font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

@media (max-width: 480px) {
  .link-card { flex-wrap: wrap; }
  .top-bar .domain-chip { display: none; }
}
