:root {
  --bg: #fff7fb;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-solid: #ffffff;
  --ink: #4c3140;
  --muted: #8a6879;
  --pink: #f7a6c8;
  --pink-strong: #de6fa2;
  --pink-soft: #ffd6e7;
  --mint: #c6f0ea;
  --mint-strong: #70bfb4;
  --cream: #fff3d8;
  --lavender: #e8ddff;
  --border: rgba(169, 97, 132, 0.18);
  --shadow: 0 22px 70px rgba(109, 63, 87, 0.14);
  --shadow-soft: 0 12px 32px rgba(109, 63, 87, 0.11);
  --radius-lg: 30px;
  --radius: 20px;
  --radius-sm: 14px;
  --focus: 0 0 0 4px rgba(112, 191, 180, 0.25);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 214, 231, 0.9), transparent 35rem),
    radial-gradient(circle at 88% 10%, rgba(198, 240, 234, 0.8), transparent 30rem),
    linear-gradient(135deg, #fff7fb 0%, #fff9ef 48%, #f9fffd 100%);
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

a {
  color: inherit;
}

.sewing-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.sewing-bg span {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: rotate(var(--r)) scale(var(--s));
  font-size: 4.4rem;
  opacity: 0.16;
  filter: blur(2.4px);
  user-select: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1240px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 56px;
}

.screen {
  display: none;
  animation: rise 240ms ease both;
}

.screen.active {
  display: block;
}

.screen-centered {
  min-height: calc(100vh - 44px);
  display: none;
  place-items: center;
}

.screen-centered.active {
  display: grid;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.glassy {
  background: rgba(255, 255, 255, 0.72);
}

.loader-card,
.auth-card {
  width: min(460px, 100%);
  text-align: center;
}

.loader-card {
  padding: 38px 28px;
}

.loader-card h1,
.auth-card h1,
.site-header h1,
.hero h2 {
  margin: 0;
  letter-spacing: -0.04em;
}

.loader-card p,
.auth-subtitle,
.hero p,
.content-head p,
.empty-state p {
  color: var(--muted);
}

.stitch-loader {
  width: 76px;
  height: 76px;
  margin: 0 auto 20px;
  border-radius: 999px;
  border: 6px dashed var(--pink-strong);
  border-top-color: var(--mint-strong);
  animation: spin 1100ms linear infinite;
}

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

.auth-card {
  padding: 34px;
}

.brand-badge,
.brand-mark {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--pink-soft), var(--mint));
  border: 1px solid rgba(212, 106, 155, 0.25);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.8), var(--shadow-soft);
  overflow: hidden;
}

.brand-badge img,
.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-badge {
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
  border-radius: 24px;
  font-size: 2.1rem;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--pink-strong);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.auth-subtitle {
  margin: 12px 0 24px;
  line-height: 1.55;
}

.auth-tabs,
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  margin: 0 0 20px;
  background: rgba(255, 214, 231, 0.38);
  border: 1px solid rgba(212, 106, 155, 0.16);
  border-radius: 18px;
}

.tab,
.segment {
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  padding: 11px 12px;
}

.tab.active,
.segment.active {
  background: var(--panel-solid);
  color: var(--ink);
  box-shadow: 0 8px 22px rgba(122, 66, 95, 0.12);
}

.stacked-form,
.dialog-body {
  display: grid;
  gap: 15px;
}

.field {
  display: grid;
  gap: 7px;
  text-align: left;
}

.field span {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
}

.field small {
  color: var(--muted);
  line-height: 1.45;
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input {
  padding-right: 78px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  border-radius: 11px;
  background: rgba(255, 214, 231, 0.58);
  color: var(--pink-strong);
  font-size: 0.82rem;
  font-weight: 900;
  padding: 7px 10px;
}

.password-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(169, 97, 132, 0.22);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  outline: none;
  padding: 13px 14px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--mint-strong);
  box-shadow: var(--focus);
  background: #fff;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  border-radius: 16px;
  padding: 12px 18px;
  font-weight: 900;
  text-decoration: none;
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: saturate(1.04);
}

.button:focus-visible,
.icon-button:focus-visible,
.mini-button:focus-visible,
.mini-link:focus-visible,
.chip-delete:focus-visible,
.tab:focus-visible,
.segment:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.primary {
  color: #5b2440;
  background: linear-gradient(135deg, #ffc4dc, #f2a2c3);
  box-shadow: 0 12px 24px rgba(222, 111, 162, 0.24);
}

.secondary {
  color: #265b55;
  background: linear-gradient(135deg, #d2f7f1, #aee5dc);
  box-shadow: 0 12px 24px rgba(112, 191, 180, 0.18);
}

.ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(169, 97, 132, 0.17);
}

.full {
  width: 100%;
}

.hidden {
  display: none !important;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  margin-bottom: 18px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  border-radius: 18px;
}

.easbroidery-link {
  margin-left: 4px;
  white-space: nowrap;
}

.site-header h1 {
  font-size: clamp(1.5rem, 2.2vw, 2.1rem);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-pill {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 10px 13px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(169, 97, 132, 0.13);
  font-size: 0.9rem;
  font-weight: 800;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: clamp(24px, 3vw, 34px);
  margin-bottom: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(255, 247, 251, 0.76)),
    radial-gradient(circle at 100% 0, rgba(198, 240, 234, 0.9), transparent 22rem);
}

.hero h2 {
  max-width: 760px;
  font-size: clamp(1.8rem, 4vw, 3.4rem);
  line-height: 0.98;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 12px;
  padding: 14px;
  margin-bottom: 18px;
}

.search-wrap {
  position: relative;
  display: block;
}

.search-wrap input {
  min-height: 52px;
  padding-left: 44px;
  border-radius: 18px;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--pink-strong);
  font-size: 1.4rem;
  font-weight: 900;
  z-index: 1;
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 160px));
  gap: 10px;
}

.filters select {
  min-height: 52px;
}

.library-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.side-panel,
.content-panel {
  padding: 18px;
}

.side-panel {
  position: sticky;
  top: 16px;
}

.side-section + .side-section {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px dashed rgba(169, 97, 132, 0.22);
}

.side-title-row,
.content-head,
.dialog-head,
.dialog-actions,
.inline-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.side-title-row h3,
.content-head h3,
.empty-state h3,
.dialog-head h2 {
  margin: 0;
}

.mini-button,
.icon-button {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: rgba(247, 166, 200, 0.26);
  color: var(--pink-strong);
  font-weight: 900;
}

.mini-button {
  width: 34px;
  height: 34px;
}

.icon-button {
  width: 40px;
  height: 40px;
  font-size: 1.5rem;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip-row {
  display: inline-flex;
  align-items: stretch;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(169, 97, 132, 0.17);
  border-right: 0;
  border-radius: 999px 0 0 999px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--ink);
  padding: 8px 10px 8px 11px;
  font-size: 0.86rem;
  font-weight: 800;
}

.chip-delete {
  display: inline-grid;
  place-items: center;
  width: 32px;
  border: 1px solid rgba(169, 97, 132, 0.17);
  border-radius: 0 999px 999px 0;
  background: rgba(255, 214, 231, 0.46);
  color: #873653;
  font-size: 1.05rem;
  font-weight: 900;
}

.chip-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--pink);
  box-shadow: inset 0 0 0 1px rgba(76, 49, 64, 0.12);
}

.empty-note {
  color: var(--muted);
  font-size: 0.92rem;
}

.content-head {
  margin-bottom: 16px;
}

.content-head p {
  margin: 4px 0 0;
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 14px;
}

.pattern-card {
  display: grid;
  gap: 12px;
  min-height: 220px;
  padding: 16px;
  border: 1px solid rgba(169, 97, 132, 0.17);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 248, 252, 0.9));
  box-shadow: 0 12px 28px rgba(109, 63, 87, 0.09);
}

.card-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.card-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 17px;
  background: linear-gradient(135deg, var(--pink-soft), var(--mint));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.75);
  font-size: 1.35rem;
}

.card-title {
  min-width: 0;
}

.card-title h4 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1.05rem;
  line-height: 1.25;
}

.card-title p,
.card-notes,
.meta-line {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.card-title p {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.meta-tags {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.meta-line {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(255, 214, 231, 0.38);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-notes {
  margin: 0;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}

.card-actions .button {
  min-height: 40px;
  padding: 9px 10px;
  border-radius: 14px;
  font-size: 0.9rem;
}

.card-actions .danger {
  color: #873653;
  background: rgba(255, 214, 231, 0.58);
  border: 1px solid rgba(222, 111, 162, 0.16);
}

.empty-state {
  padding: 48px 22px;
  text-align: center;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}

.skeleton {
  min-height: 220px;
  border-radius: 24px;
  background: linear-gradient(90deg, rgba(255,255,255,.55), rgba(255,214,231,.45), rgba(255,255,255,.55));
  background-size: 220% 100%;
  animation: shimmer 1.1s ease infinite;
}

@keyframes shimmer {
  to { background-position: -220% 0; }
}

.dialog {
  width: min(620px, calc(100% - 26px));
  max-height: calc(100vh - 28px);
  border: 0;
  padding: 0;
  color: var(--ink);
}

.dialog::backdrop {
  background: rgba(76, 49, 64, 0.28);
  backdrop-filter: blur(6px);
}

.dialog-body {
  padding: 24px;
}

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

.file-drop input {
  border-style: dashed;
  background: rgba(255, 214, 231, 0.18);
}

.inline-actions {
  justify-content: flex-start;
  margin-top: -5px;
}

.mini-link {
  border: 0;
  background: transparent;
  color: var(--pink-strong);
  font-weight: 900;
  padding: 6px 2px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  max-width: min(390px, calc(100vw - 36px));
  transform: translateY(12px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid rgba(169, 97, 132, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  color: var(--ink);
  padding: 13px 15px;
  font-weight: 800;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: rgba(166, 54, 87, 0.28);
  color: #873653;
}

@media (max-width: 920px) {
  .toolbar,
  .library-layout {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .side-panel {
    position: static;
  }
}

@media (max-width: 700px) {
  .app-shell {
    width: min(100% - 18px, 1240px);
    padding-top: 9px;
  }

  .site-header,
  .hero,
  .content-head,
  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-lockup {
    flex-wrap: wrap;
  }

  .easbroidery-link {
    flex: 1 1 100%;
    margin-left: 0;
  }

  .header-actions {
    justify-content: stretch;
  }

  .header-actions > * {
    flex: 1;
  }

  .hero h2 {
    font-size: 2rem;
    line-height: 1.06;
  }

  .filters,
  .form-grid,
  .card-actions {
    grid-template-columns: 1fr;
  }

  .auth-card,
  .dialog-body,
  .side-panel,
  .content-panel {
    padding: 18px;
  }

  .sewing-bg span {
    font-size: 3rem;
  }
}
