:root {
  --sage: #6f8465;
  --sage-dark: #42533c;
  --sage-light: #dfe7da;
  --gold: #bd9452;
  --cream: #f5f1e7;
  --paper: #fffdf8;
  --ink: #263022;
  --muted: #6f7869;
  --line: #dfe3d9;
  --danger: #a85048;
  --shadow: 0 18px 55px rgba(56, 68, 49, .12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.eyebrow { color: var(--sage); font-size: .7rem; font-weight: 800; letter-spacing: .16em; }
.muted, .hint { color: var(--muted); line-height: 1.6; }
.hint { font-size: .77rem; text-align: center; }

.loading-screen {
  min-height: 100vh; display: grid; place-content: center; text-align: center;
  background: radial-gradient(circle at 50% 40%, #fff 0, var(--cream) 55%);
  color: var(--muted);
}
.thread-mark { color: var(--gold); font-size: 2rem; animation: breathe 1.5s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .35; transform: scale(.86); } }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); }
.auth-brand {
  position: relative; overflow: hidden; padding: clamp(48px, 8vw, 120px);
  display: flex; flex-direction: column; justify-content: center;
  background: var(--sage-dark); color: #fff;
}
.auth-brand::after {
  content: ""; position: absolute; width: 360px; height: 360px; border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%; right: -100px; top: -100px; box-shadow: 0 0 0 70px rgba(255,255,255,.025), 0 0 0 140px rgba(255,255,255,.02);
}
.auth-brand .eyebrow { color: #d5c091; }
.auth-brand h1, .profile-hero h1 {
  font-family: Georgia, "Times New Roman", serif; font-weight: 400; line-height: 1.04;
}
.auth-brand h1 { font-size: clamp(2.8rem, 5vw, 5rem); margin: 22px 0; max-width: 720px; }
.auth-brand em { color: #d5c091; font-weight: 400; }
.auth-brand > p { color: #d8dfd4; max-width: 530px; line-height: 1.7; }
.patch-preview { display: grid; grid-template-columns: repeat(4, 32px); margin-top: 40px; transform: rotate(45deg); width: max-content; }
.patch-preview span { width: 32px; height: 32px; background: #92a387; border: 1px solid rgba(255,255,255,.18); }
.patch-preview span:nth-child(3n), .patch-preview span:nth-child(5n) { background: #c29c5d; }
.patch-preview span:nth-child(4n), .patch-preview span:nth-child(7n) { background: #f2ede0; }
.auth-card { background: var(--paper); display: grid; place-items: center; padding: 32px; }
.auth-card > div { width: min(100%, 430px); }
.auth-card h2 { font-family: Georgia, serif; font-size: 2rem; font-weight: 400; margin: 8px 0; }
.mobile-brand { display: none; color: var(--sage); font-family: Georgia, serif; font-size: 1.2rem; }
label { display: block; font-size: .76rem; font-weight: 750; margin: 18px 0 7px; }
input, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px 13px;
  background: #fff; color: var(--ink); outline: none; transition: border .15s, box-shadow .15s;
}
select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px 13px;
  background: #fff; color: var(--ink); outline: none;
}
select:focus { border-color: var(--sage); box-shadow: 0 0 0 3px rgba(111,132,101,.13); }
input:focus, textarea:focus { border-color: var(--sage); box-shadow: 0 0 0 3px rgba(111,132,101,.13); }
textarea { resize: vertical; }
.button {
  border: 1px solid transparent; border-radius: 10px; min-height: 42px; padding: 10px 17px;
  cursor: pointer; font-size: .84rem; font-weight: 750; transition: transform .15s, background .15s;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button.primary { background: var(--sage); color: #fff; }
.button.primary:hover { background: var(--sage-dark); }
.button.secondary { background: #fff; border-color: var(--line); }
.button.secondary:hover { border-color: var(--sage); }
.button.wide { width: 100%; margin-top: 18px; }
.button.compact { min-height: 36px; padding: 7px 13px; }
.text-button { display: block; margin: 13px auto 0; border: 0; background: none; color: var(--sage-dark); cursor: pointer; font-size: .8rem; }
.text-button.inline { display: inline; margin: 0; padding: 0; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.auth-switch { margin: 22px 0 0; text-align: center; color: var(--muted); font-size: .82rem; }
.divider { height: 1px; background: var(--line); margin: 25px 0; text-align: center; }
.divider span { position: relative; top: -9px; padding: 0 12px; background: var(--paper); color: var(--muted); font-size: .74rem; }
.message { display: none; margin-top: 12px; border-radius: 9px; padding: 10px 12px; font-size: .8rem; line-height: 1.45; }
.message.show { display: block; }
.message.ok { color: #45643b; background: #e8f0e3; }
.message.error { color: var(--danger); background: #f5e7e4; }
.redirect-view { text-align: center; }

.dashboard { min-height: 100vh; padding-bottom: 40px; background: var(--cream); }
.topbar {
  position: sticky; top: 0; z-index: 20; height: 72px; display: flex; align-items: center;
  padding: 0 clamp(20px, 4vw, 64px); background: rgba(255,253,248,.94); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.wordmark { display: flex; align-items: center; gap: 11px; flex: 0 0 auto; color: var(--ink); text-decoration: none; }
.wordmark-mark {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px;
  background: var(--sage); color: #fff; font: 23px/1 Georgia, serif;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}
.wordmark-copy strong { display: block; font: 700 19px/1.1 Georgia, serif; letter-spacing: .01em; }
.wordmark-copy small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; letter-spacing: .17em; text-transform: uppercase; }
.desktop-nav { display: flex; gap: 3px; margin: auto; }
.nav-link { border: 0; background: transparent; padding: 25px 13px 22px; font-size: .78rem; cursor: pointer; border-bottom: 3px solid transparent; }
.nav-link.active { color: var(--sage-dark); border-color: var(--sage); font-weight: 800; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.notification-menu { position: relative; }
.notification-trigger { min-height: 40px; padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-weight: 800; }
.notification-trigger:hover, .notification-trigger[aria-expanded="true"] { color: var(--sage-dark); }
.notification-bell { display: none; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.notification-popover {
  position: absolute; z-index: 40; top: calc(100% + 10px); right: 0; width: min(370px, calc(100vw - 28px));
  overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: var(--shadow);
}
.notification-popover-title { padding: 15px 17px; border-bottom: 1px solid var(--line); font: 400 1.08rem Georgia, serif; }
.account-menu { position: relative; }
.avatar-button { border: 0; background: transparent; display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 6px; border-radius: 10px; }
.avatar-button:hover { background: var(--cream); }
.account-copy { display: grid; text-align: left; }
.account-copy strong { font-size: .78rem; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-copy small { color: var(--muted); font-size: .65rem; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { flex: 0 0 auto; display: grid; place-items: center; overflow: hidden; border-radius: 50%; background: var(--sage); color: white; font-family: Georgia, serif; }
.avatar.small { width: 34px; height: 34px; font-size: .85rem; }
.avatar.large { width: 96px; height: 96px; border: 6px solid rgba(255,255,255,.65); box-shadow: 0 6px 20px rgba(45,59,39,.16); font-size: 2rem; }
.account-popover { position: absolute; right: 0; top: calc(100% + 8px); width: 190px; padding: 7px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.account-popover button { border: 0; background: transparent; width: 100%; text-align: left; padding: 10px; cursor: pointer; border-radius: 8px; font-size: .8rem; }
.account-popover button:hover { background: var(--cream); }

.dashboard-main { width: min(1240px, calc(100% - 40px)); margin: 0 auto; }
.profile-hero {
  margin-top: 28px; min-height: 245px; border-radius: 22px; padding: clamp(28px, 5vw, 58px);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 28px;
  color: #fff; background:
    radial-gradient(circle at 85% -25%, rgba(213,192,145,.32), transparent 40%),
    linear-gradient(125deg, #405039, #6c8162);
  box-shadow: var(--shadow);
}
.profile-intro h1 { margin: 7px 0 8px; font-size: clamp(2rem, 4vw, 3.6rem); }
.profile-intro .eyebrow { color: #ddc999; }
.profile-intro p { color: #e1e7de; margin: 0 0 15px; max-width: 560px; }
.profile-hero .button.secondary { border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.1); color: white; }
.profile-stats { display: grid; grid-template-columns: repeat(2, 100px); gap: 10px; }
.profile-stats div { padding: 14px; text-align: center; border: 1px solid rgba(255,255,255,.18); border-radius: 13px; background: rgba(255,255,255,.07); }
.profile-stats strong, .profile-stats span { display: block; }
.profile-stats strong { font-family: Georgia, serif; font-size: 1.5rem; }
.profile-stats span { margin-top: 3px; color: #dbe3d7; font-size: .67rem; }

.content-section, .apps-section { padding-top: 48px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.section-heading h2 { margin: 5px 0 0; font-family: Georgia, serif; font-weight: 400; font-size: clamp(1.55rem, 2.4vw, 2.1rem); }
.section-heading > p { color: var(--muted); font-size: .8rem; margin: 0; }
.section-heading-actions { display: flex; align-items: center; gap: 14px; }
.section-heading-actions > p { color: var(--muted); font-size: .8rem; margin: 0; }
.fabric-reuse-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 22px; margin: 0 0 18px;
  padding: 16px 18px; border: 1px solid #d8dfd2; border-radius: 14px; background: #f0f4ec;
}
.fabric-reuse-bar > div:first-child { display: grid; gap: 4px; }
.fabric-reuse-bar strong { font: 500 1rem Georgia, serif; }
.fabric-reuse-bar span { color: var(--muted); font-size: .72rem; }
.reuse-destinations { display: flex; flex-wrap: wrap; gap: 7px; }
.reuse-destinations a {
  padding: 7px 10px; border: 1px solid #cbd5c4; border-radius: 999px; background: #fff;
  color: var(--sage-dark); font-size: .68rem; font-weight: 800; text-decoration: none;
}
.reuse-destinations a:hover { border-color: var(--sage); }
.fabric-set-bar { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 2px; }
.fabric-set-chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; background: #fff;
  color: var(--muted); cursor: pointer; font-size: .72rem; font-weight: 750;
}
.fabric-set-chip.active { border-color: var(--sage); background: var(--sage); color: #fff; }
.fabric-card-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.asset-link.as-button { padding: 0; border: 0; background: transparent; cursor: pointer; }
.asset-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.asset-card {
  min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 15px;
  background: var(--paper); transition: transform .18s, box-shadow .18s;
}
.asset-card:hover { transform: translateY(-3px); box-shadow: 0 12px 35px rgba(56,68,49,.11); }
.asset-thumb { aspect-ratio: 1 / 1; display: grid; place-items: center; overflow: hidden; background: #e7ebdf; color: var(--sage); font-family: Georgia, serif; font-size: 2rem; }
.asset-thumb img { width: 100%; height: 100%; object-fit: cover; }
.asset-thumb.quilt { aspect-ratio: 3 / 4; background: linear-gradient(45deg, #d9e2d2 25%, #f4efe3 25% 50%, #c6a66a 50% 75%, #e8ede2 75%); background-size: 46px 46px; }
.asset-thumb.project { background: radial-gradient(circle, #faf6eb 15%, transparent 16%), #9bae91; background-size: 25px 25px; }
.asset-thumb.purchase { background: #eee5d2; }
.asset-body { padding: 14px; }
.asset-meta { color: var(--sage); font-size: .65rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.asset-body h3 { margin: 7px 0 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: Georgia, serif; font-size: 1.03rem; font-weight: 500; }
.asset-body p { margin: 0; color: var(--muted); font-size: .72rem; line-height: 1.5; }
.asset-link { display: inline-block; margin-top: 12px; color: var(--sage-dark); font-size: .73rem; font-weight: 800; text-decoration: none; }
.empty-state, .loading-state { grid-column: 1 / -1; padding: 52px 20px; text-align: center; border: 1px dashed #cfd5c7; border-radius: 15px; background: rgba(255,255,255,.48); }
.empty-state strong { display: block; font-family: Georgia, serif; font-size: 1.2rem; margin-bottom: 6px; }
.empty-state p, .loading-state { color: var(--muted); font-size: .82rem; }
.empty-state .button { display: inline-flex; align-items: center; text-decoration: none; margin-top: 10px; }

.app-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.app-card { display: flex; align-items: center; gap: 12px; padding: 15px; background: var(--paper); border: 1px solid var(--line); border-radius: 13px; }
.app-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--sage-light); color: var(--sage-dark); }
.app-copy { min-width: 0; flex: 1; }
.app-copy strong, .app-copy small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-copy strong { font-size: .8rem; }
.app-copy small { color: var(--muted); font-size: .65rem; margin-top: 3px; }
.app-open { color: var(--sage-dark); text-decoration: none; font-size: .72rem; font-weight: 800; }
.app-card.unknown { border-color: #d7bd88; background: #fffaf0; }
.app-card.unknown .app-icon { background: #f2e6c9; color: #85672f; }
.app-card.unverified { border-style: dashed; }
.app-card.unverified .app-copy small { color: #7b735f; }
.mobile-nav { display: none; }

.modal { width: min(530px, calc(100% - 28px)); border: 0; border-radius: 17px; padding: 0; color: var(--ink); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(28,36,25,.55); backdrop-filter: blur(3px); }
.modal form { padding: 24px; }
.notification-list { max-height: min(430px, 60vh); overflow-y: auto; }
.notification-list article { display: grid; gap: 9px; padding: 15px 17px; border-bottom: 1px solid var(--line); transition: opacity .18s, background .18s; }
.notification-list article.is-unread { background: #fafbf7; box-shadow: inset 3px 0 var(--sage); }
.notification-list article.is-read { opacity: .55; }
.notification-list a, .notification-copy { display: grid; gap: 4px; color: inherit; text-decoration: none; }
.notification-list a:hover strong { color: var(--sage-dark); }
.notification-list small { color: #a06e68; font-size: .62rem; letter-spacing: .08em; }
.notification-list strong { font: 400 1rem/1.35 Georgia, serif; }
.notification-list span { color: var(--muted); font-size: .74rem; line-height: 1.5; }
.notification-list button { justify-self: start; padding: 0; border: 0; background: transparent; color: var(--sage-dark); font-size: .68rem; }
.notification-list button:disabled { color: var(--muted); cursor: default; }
.notification-empty { margin: 0; padding: 30px 17px; color: var(--muted); font-size: .78rem; text-align: center; }
.notification-hocquilt-link { width: 100%; padding: 11px 17px; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: #f7f5ef; color: var(--muted); cursor: not-allowed; font-size: .72rem; text-align: left; opacity: .65; }
.notification-hocquilt-link span { margin-left: 5px; font-size: .66rem; }
.modal-heading { display: flex; justify-content: space-between; gap: 20px; }
.modal-heading h2 { font-family: Georgia, serif; font-weight: 400; margin: 5px 0; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: #fff; cursor: pointer; font-size: 1.25rem; }
.optional { color: var(--muted); font-weight: 400; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }

.pattern-modal-thumb {
  width: 100%; margin: 4px 0 12px; border-radius: 12px;
  overflow: hidden; display: grid; place-items: center; background: #eee5d2; color: var(--sage);
  font-family: Georgia, serif; font-size: 2rem; padding: 40px 0;
}
.pattern-modal-thumb:has(img) { padding: 0; }
.pattern-modal-thumb img { display: block; max-width: 100%; max-height: min(60vh, 440px); width: auto; height: auto; }
.pattern-modal-actions { display: grid; gap: 9px; margin-top: 14px; }
.pattern-modal-actions .button { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; text-align: center; }
.fabric-upload-modal { width: min(680px, calc(100% - 28px)); }
.fabric-drop-zone {
  display: grid; place-items: center; gap: 7px; margin-top: 16px; padding: 30px 18px;
  border: 1.5px dashed #b7c4af; border-radius: 14px; background: #f7f8f3; cursor: pointer; text-align: center;
}
.fabric-drop-zone:hover, .fabric-drop-zone:focus, .fabric-drop-zone.drag { border-color: var(--sage); background: #eef3ea; outline: none; }
.fabric-drop-zone strong { font: 500 1.05rem Georgia, serif; }
.fabric-drop-zone span { color: var(--muted); font-size: .72rem; }
.fabric-drop-zone small { color: var(--sage-dark); font-size: .68rem; font-weight: 750; }
.fabric-preview-list { display: grid; gap: 8px; max-height: 220px; overflow-y: auto; margin-top: 12px; }
.fabric-preview-row {
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 7px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.fabric-preview-row img { width: 48px; height: 48px; object-fit: cover; border-radius: 7px; }
.fabric-preview-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .76rem; }
.fabric-preview-row button { border: 0; background: transparent; color: var(--danger); cursor: pointer; font-size: 1.2rem; }
.fabric-upload-success { margin-top: 14px; padding: 15px; border-radius: 12px; background: #e8f0e3; color: #45643b; }
.fabric-upload-success p { margin: 5px 0 11px; font-size: .76rem; }
.fabric-set-checklist { display: grid; gap: 8px; margin-top: 16px; }
.fabric-set-option {
  display: flex; align-items: center; gap: 10px; margin: 0; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer;
}
.fabric-set-option input { width: auto; margin: 0; }
.fabric-set-option span { font-size: .8rem; }

@media (max-width: 960px) {
  .asset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-hero { grid-template-columns: auto 1fr; }
  .profile-stats { grid-column: 1 / -1; grid-template-columns: repeat(5, 1fr); }
  .desktop-nav { display: none; }
}

@media (max-width: 680px) {
  .auth-shell { display: block; background: var(--paper); }
  .auth-brand { display: none; }
  .auth-card { min-height: 100vh; padding: 28px 22px; }
  .mobile-brand { display: block; margin-bottom: 42px; }
  .topbar { height: 62px; padding: 0 16px; }
  .wordmark-copy { display: none; }
  .topbar-actions { margin-left: auto; gap: 7px; }
  .notification-trigger { width: 40px; display: grid; place-items: center; border-radius: 50%; }
  .notification-trigger:hover, .notification-trigger[aria-expanded="true"] { background: var(--cream); }
  .notification-label { display: none; }
  .notification-bell { display: block; }
  .notification-popover { position: fixed; top: 68px; right: 10px; }
  .account-copy, .avatar-button > span:last-child { display: none; }
  .dashboard { padding-bottom: 92px; }
  .dashboard-main { width: min(100% - 28px, 600px); }
  .profile-hero { margin-top: 14px; padding: 25px 20px; grid-template-columns: 62px 1fr; gap: 15px; }
  .avatar.large { width: 62px; height: 62px; border-width: 4px; font-size: 1.25rem; }
  .profile-intro h1 { font-size: 1.85rem; }
  .profile-intro p { font-size: .78rem; }
  .profile-stats { gap: 6px; }
  .profile-stats div { padding: 10px 4px; }
  .profile-stats strong { font-size: 1.15rem; }
  .content-section, .apps-section { padding-top: 34px; }
  .section-heading { display: block; }
  .section-heading > p { margin-top: 7px; }
  .section-heading-actions { display: grid; justify-items: start; margin-top: 9px; }
  .fabric-reuse-bar { display: grid; }
  .asset-grid, .app-grid { grid-template-columns: 1fr; }
  .asset-card { display: grid; grid-template-columns: 112px minmax(0, 1fr); }
  .asset-thumb { height: 100%; min-height: 130px; }
  .app-grid { gap: 8px; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; z-index: 30; bottom: 0; left: 0; right: 0;
    padding: 7px 5px max(7px, env(safe-area-inset-bottom)); background: rgba(255,253,248,.96);
    border-top: 1px solid var(--line); backdrop-filter: blur(18px);
  }
  .mobile-nav button { border: 0; background: transparent; display: grid; justify-items: center; gap: 2px; color: var(--muted); font-size: .61rem; min-height: 45px; cursor: pointer; }
  .mobile-nav button span { font-size: 1.05rem; }
  .mobile-nav button.active { color: var(--sage-dark); font-weight: 800; }
  .modal { margin-bottom: 0; border-radius: 17px 17px 0 0; }
}

@media (max-width: 390px) {
  .profile-intro .eyebrow { display: none; }
  .profile-hero { grid-template-columns: 54px 1fr; }
  .avatar.large { width: 54px; height: 54px; }
  .profile-stats span { font-size: .58rem; }
  .mobile-nav button { font-size: .55rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
