@font-face {
    font-family: "Cormorant Garamond";
    src: url("/static/fonts/CormorantGaramond-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Cormorant Garamond";
    src: url("/static/fonts/CormorantGaramond-SemiBold.ttf") format("truetype");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Cormorant Garamond";
    src: url("/static/fonts/CormorantGaramond-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Manrope";
    src: url("/static/fonts/Manrope-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Manrope";
    src: url("/static/fonts/Manrope-Medium.ttf") format("truetype");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Manrope";
    src: url("/static/fonts/Manrope-SemiBold.ttf") format("truetype");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Space Grotesk";
    src: url("/static/fonts/SpaceGrotesk-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Space Grotesk";
    src: url("/static/fonts/SpaceGrotesk-Medium.ttf") format("truetype");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Space Grotesk";
    src: url("/static/fonts/SpaceGrotesk-SemiBold.ttf") format("truetype");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

:root {
    --ink: #e7edf4;
    --muted: #a8b3c0;
    --accent: #ff8a66;
    --accent-2: #3ad1b9;
    --card: rgba(20, 26, 34, 0.88);
    --shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
    --shadow-hover: 0 22px 46px rgba(0, 0, 0, 0.45);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html[data-i18n-pending="true"] body {
    opacity: 0;
}

textarea {
  resize: none;
}

body {
    font-family: "Manrope", "Segoe UI", sans-serif;
    margin: 0;
    padding: 28px 24px 40px;
    color: var(--ink);
    min-height: 100vh;
    background:
        radial-gradient(800px 500px at 15% -10%, rgba(255, 138, 102, 0.18), transparent 55%),
        radial-gradient(900px 600px at 85% 10%, rgba(58, 209, 185, 0.16), transparent 60%),
        linear-gradient(180deg, #0d1218 0%, #121a22 60%, #111820 100%);
    transition: opacity 120ms ease;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 28px;
}

nav a {
    text-decoration: none;
    color: var(--ink);
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(231, 237, 244, 0.08);
    box-shadow: inset 0 0 0 rgba(0, 0, 0, 0);
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

nav a:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

nav a.current {
    background: linear-gradient(135deg, #f08b63, #2fbba8);
    color: #ffffff;
    cursor: default;
    transform: none;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
}

#week {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

#addDialog{
    position: absolute;
    max-height:0px;
    overflow: hidden;
    background: var(--card);
    border-radius: 16px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(6px);
    transition: all 180ms ease;
    animation: fade-up 420ms ease both;
}
.addDialog-header{
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
}
.addDialog-header label{
    color: var(--muted);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}
.addDialog-header select{
    margin-top: 0;
}
.icon-button{
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: var(--ink);
    width: 32px;
    height: 32px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
.icon-button:hover{
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
    box-shadow: 0 8px 14px rgba(0, 0, 0, 0.3);
}
.addDialog-actions{
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.choose-list{
    display: grid;
    gap: 8px;
    margin-top: 12px;
    max-height: 260px;
    overflow-y: auto;
}
.choose-notice{
    margin-top: 10px;
    color: var(--muted);
    font-style: italic;
}
.choose-option{
    width: 100%;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    cursor: pointer;
    text-align: left;
    transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
.choose-option:hover{
    background: rgba(255, 255, 255, 0.14);
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}
.dialog-button{
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    cursor: pointer;
    transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
.dialog-button:hover{
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.35);
}
.dialog-primary{
    background: linear-gradient(135deg, rgba(255, 138, 102, 0.4), rgba(58, 209, 185, 0.24));
    color: var(--ink);
}
.dialog-primary:hover{
    background: linear-gradient(135deg, rgba(255, 138, 102, 0.55), rgba(58, 209, 185, 0.32));
}
.dialog-ghost{
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
}
.dialog-ghost:hover{
    background: rgba(255, 255, 255, 0.14);
}
.page {
    max-width: 1300px;
    padding: 20px;
    border-radius: 16px;
    background: var(--card);
    border: 1px solid rgba(231, 237, 244, 0.08);
    box-shadow: var(--shadow);
}

.page h1 {
    margin: 0 0 12px 0;
    font-size: 1.6rem;
    letter-spacing: 0.02em;
}
.recipe-list{
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin-top: 12px;
    width: 100%;
}
.recipe-link{
    display: block;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
    text-decoration: none;
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    transition: transform 140ms ease, background 140ms ease, border 140ms ease;
}
.recipe-link:hover{
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(231, 237, 244, 0.2);
    transform: translateY(-1px);
}
.recipe-link[data-category="biglunch"]{
    background: rgba(255, 138, 102, 0.16);
    border-color: rgba(255, 138, 102, 0.28);
}
.recipe-link[data-category="smalllunch"]{
    background: rgba(58, 209, 185, 0.16);
    border-color: rgba(58, 209, 185, 0.28);
}
.recipe-link[data-category="workmeal"]{
    background: rgba(126, 166, 255, 0.16);
    border-color: rgba(126, 166, 255, 0.3);
}
.recipe-link[data-category="dinner"]{
    background: rgba(255, 204, 107, 0.18);
    border-color: rgba(255, 204, 107, 0.3);
}
.recipe-link[data-category="singleservings"]{
    background: rgba(188, 146, 255, 0.16);
    border-color: rgba(188, 146, 255, 0.3);
}
.recipe-link[data-category="cake"]{
    background: rgba(255, 128, 187, 0.16);
    border-color: rgba(255, 128, 187, 0.3);
}
.shopping-list{
    display: grid;
    gap: 10px;
    margin-top: 10px;
    max-width: 720px;
    width: 100%;
}
.shopping-dialog{
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.98);
    width: min(92vw, 420px);
    padding: 18px;
    border-radius: 16px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: var(--card);
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
    z-index: 20;
}
.shopping-dialog.is-open{
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}
.shopping-dialog-header{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.shopping-dialog h2{
    margin: 0;
    font-size: 1.1rem;
}
.shopping-dialog label{
    display: block;
    margin-top: 10px;
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    color: var(--muted);
}
.shopping-dialog input{
    width: 100%;
    margin-top: 6px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
}
.shopping-dialog-actions{
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}
.shopping-item{
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.06);
    align-items: center;
}
.shopping-item-name{
    color: var(--ink);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}
.shopping-item-amount{
    color: var(--muted);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    text-align: right;
}
.shopping-delete{
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(255, 138, 102, 0.18);
    color: #ffe7df;
    cursor: pointer;
    transition: transform 140ms ease, background 140ms ease, border 140ms ease;
}
.shopping-delete:hover{
    background: rgba(255, 138, 102, 0.3);
    border-color: rgba(255, 138, 102, 0.4);
    transform: translateY(-1px);
}
.shopping-empty{
    color: var(--muted);
    font-style: italic;
    margin: 0;
}

.chatPage{
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    gap: 18px;
    width: calc(100vw - 52px);
    height: 85vh;
    padding: 20px;
    border-radius: 16px;
    background: var(--card);
    border: 1px solid rgba(231, 237, 244, 0.08);
    box-shadow: var(--shadow);
}
.chatcontainer{
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    border-radius: 14px;
    border: 1px solid rgba(231, 237, 244, 0.08);
    background: rgba(11, 16, 22, 0.6);
    height: 100%;
    min-height: 0;
}
.log{
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding: 8px;
    height: 100%;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}
.log:empty::before{
    content: "Nachrichten erscheinen hier.";
    color: var(--muted);
    font-style: italic;
    padding: 8px 6px;
}
.input{
    width: 100%;
    min-height: 80px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    flex: 0 0 auto;
}
.input:focus{
    outline: 2px solid rgba(58, 209, 185, 0.5);
    outline-offset: 2px;
}
.input[readonly]{
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(231, 237, 244, 0.08);
    color: rgba(231, 237, 244, 0.6);
    cursor: not-allowed;
}
.input[readonly]:focus{
    outline-color: rgba(231, 237, 244, 0.25);
}
.recipe{
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
    border-radius: 14px;
    border: 1px solid rgba(231, 237, 244, 0.08);
    background: rgba(11, 16, 22, 0.6);
    overflow-y: auto;
    height: 100%;
    min-height: 0;
    position: relative;
}
.recipe-editor{
    display: grid;
    gap: 10px;
    margin: 10px 0 16px;
}
.recipe-editor input,
.recipe-editor textarea{
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}
.recipe-editor textarea{
    min-height: 140px;
    resize: vertical;
}
.recipe.has-recipe{
    padding-top: 54px;
}
.recipe.animate{
    animation: recipe-panel 320ms ease both;
}
.recipe.animate > *{
    animation: recipe-reveal 360ms ease both;
}
.save-recipe{
    position: absolute;
    top: 14px;
    right: 14px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(58, 209, 185, 0.16);
    color: var(--ink);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.save-recipe:hover{
    background: rgba(58, 209, 185, 0.28);
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.35);
}
.recipe:empty::before{
    content: "Rezept erscheint hier, sobald es erstellt wird.";
    color: var(--muted);
    font-style: italic;
}
.recipe h1{
    margin: 0;
    font-size: 1.4rem;
    line-height: 1.2;
}
.recipe label{
    display: block;
    margin-top: 10px;
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    color: var(--muted);
}
select{
    margin-top: 6px;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
    color-scheme: inherit;
}
select option{
    background: var(--card-strong);
    color: var(--ink);
}

.dialog-button:disabled,
.dialog-button[disabled],
.dialog-button.is-disabled,
.icon-button:disabled,
.icon-button[disabled] {
    opacity: 0.62;
    color: var(--muted);
    background: var(--card-muted);
    border-color: var(--line);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}
.message{
    max-width: 70%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.06);
    line-height: 1.4;
}
.message.agent{
    align-self: flex-end;
    background: rgba(58, 209, 185, 0.12);
}
.message.thinking{
    font-style: italic;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.04);
    width: fit-content;
}
.message.thinking.thinking-chat{
    min-width: 14ch;
}
.message.thinking.thinking-tool{
    min-width: 28ch;
}
.message.user{
    align-self: flex-start;
    background: rgba(255, 138, 102, 0.12);
    
}
.message.system{
    align-self: center;
    background: transparent;
    border: 1px dashed rgba(231, 237, 244, 0.25);
    color: var(--muted);
    font-style: italic;
}
.ingredients{
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}
.ingredients button{
    align-self: center;
    justify-self: center;
    font-size: xx-large;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(58, 209, 185, 0.16);
    color: var(--ink);
    cursor: pointer;
}
#addButton{
    grid-column: 1 / -1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 56px;
    padding: 12px 16px;
    font-size: 1.05rem;
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    border-radius: 14px;
    border-style: dashed;
    background: linear-gradient(135deg, rgba(58, 209, 185, 0.16), rgba(255, 255, 255, 0.04));
    transition: transform 160ms ease, border 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
#addButton::after{
    content: "Zutat hinzufuegen";
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}
#addButton:hover{
    transform: translateY(-1px);
    border-color: rgba(231, 237, 244, 0.35);
    background: linear-gradient(135deg, rgba(58, 209, 185, 0.26), rgba(255, 255, 255, 0.08));
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.35);
}
.ingredients-card{
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 6px;
    padding: 8px;
    border-radius: 10px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.04);
    align-items: start;
}
.ingredients-card input:nth-of-type(1){
    grid-column: 1;
    grid-row: 1;
}
.ingredients-card input:nth-of-type(2){
    grid-column: 1;
    grid-row: 2;
}
.ingredients-card input{
    width: 100%;
    min-width: 0;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: var(--ink);
}
.ingredients-card button{
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: stretch;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: medium;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 138, 102, 0.18);
    color: var(--ink);
    cursor: pointer;
}
.instructions{
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.04);
}

.log,
.recipe{
    scrollbar-width: thin;
    scrollbar-color: rgba(231, 237, 244, 0.3) transparent;
}

.log::-webkit-scrollbar,
.recipe::-webkit-scrollbar{
    width: 10px;
}

.log::-webkit-scrollbar-track,
.recipe::-webkit-scrollbar-track{
    background: transparent;
}

.log::-webkit-scrollbar-thumb,
.recipe::-webkit-scrollbar-thumb{
    background: rgba(231, 237, 244, 0.22);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.log:hover::-webkit-scrollbar-thumb,
.recipe:hover::-webkit-scrollbar-thumb{
    background: rgba(231, 237, 244, 0.38);
}
.day {
    position: relative;
    background: var(--card);
    border-radius: 16px;
    padding: 18px;
    border: 1px solid rgba(231, 237, 244, 0.08);
    box-shadow: var(--shadow);
    backdrop-filter: blur(6px);
    transition: transform 180ms ease, box-shadow 180ms ease;
    animation: fade-up 420ms ease both;
}

.day::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: linear-gradient(120deg, rgba(255, 138, 102, 0.18), rgba(58, 209, 185, 0.1));
    opacity: 0;
    transition: opacity 180ms ease;
    pointer-events: none;
}

.day:hover {
    transform: translateY(-6px) scale(1.02) rotate(-0.15deg);
    box-shadow: var(--shadow-hover);
}

.day:hover::after {
    opacity: 1;
}

.day h3 {
    margin: 0 0 12px 0;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.day button {
    display: block;
    width: 100%;
    margin: 8px 0;
    padding: 9px 12px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    cursor: pointer;
    color: var(--muted);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    transition: transform 140ms ease, background 140ms ease, border 140ms ease;
}

.day button:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(231, 237, 244, 0.2);
    transform: translateY(-2px);
}
.weekplan-item{
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 4rem;
    padding: 8px 46px 8px 10px;
    margin: 8px 0;
    border-radius: 10px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.05);
}
.weekplan-item[data-item-type="biglunch"]{
    background: rgba(255, 138, 102, 0.16);
    border-color: rgba(255, 138, 102, 0.28);
}
.weekplan-item[data-item-type="smalllunch"]{
    background: rgba(58, 209, 185, 0.16);
    border-color: rgba(58, 209, 185, 0.28);
}
.weekplan-item[data-item-type="workmeal"]{
    background: rgba(126, 166, 255, 0.16);
    border-color: rgba(126, 166, 255, 0.3);
}
.weekplan-item[data-item-type="dinner"]{
    background: rgba(255, 204, 107, 0.18);
    border-color: rgba(255, 204, 107, 0.3);
}
.weekplan-item[data-item-type="singleservings"]{
    background: rgba(188, 146, 255, 0.16);
    border-color: rgba(188, 146, 255, 0.3);
}
.weekplan-item[data-item-type="cake"]{
    background: rgba(255, 128, 187, 0.16);
    border-color: rgba(255, 128, 187, 0.3);
}
.weekplan-actions{
    position: absolute;
    top: -10px;
    right: -1px;
    display: inline-flex;
    gap: 2px;
}
.weekplan-item a{
    flex: 1 1 auto;
    color: var(--ink);
    text-decoration: none;
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}
.weekplan-item a:hover{
    text-decoration: underline;
}
.weekplan-action{
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
    cursor: pointer;
    transition: transform 140ms ease, background 140ms ease, border 140ms ease;
}
.weekplan-action:first-child{
    background: rgba(58, 209, 185, 0.16);
    border-color: rgba(58, 209, 185, 0.28);
    color: #dbfff8;
}
.weekplan-action:last-child{
    background: rgba(255, 138, 102, 0.18);
    border-color: rgba(255, 138, 102, 0.3);
    color: #ffe7df;
}
.weekplan-action:hover{
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(231, 237, 244, 0.2);
    transform: translateY(-1px);
}

#week .day:nth-child(1) { animation-delay: 20ms; }
#week .day:nth-child(2) { animation-delay: 60ms; }
#week .day:nth-child(3) { animation-delay: 100ms; }
#week .day:nth-child(4) { animation-delay: 140ms; }
#week .day:nth-child(5) { animation-delay: 180ms; }
#week .day:nth-child(6) { animation-delay: 220ms; }
#week .day:nth-child(7) { animation-delay: 260ms; }

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes recipe-panel {
    from {
        opacity: 0.65;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes recipe-reveal {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 960px) {
    body {
        padding: 18px 14px 22px;
    }

    .page {
        padding: 14px;
    }

    .chatPage {
        grid-template-columns: 1fr;
        width: 100%;
        height: auto;
        min-height: calc(100dvh - 130px);
        padding: 14px;
    }

    .chatcontainer,
    .recipe {
        min-height: 0;
    }

    .recipe {
        padding: 14px;
    }

    .shopping-item {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "name delete"
            "amount delete";
        gap: 8px 10px;
    }

    .shopping-item-name {
        grid-area: name;
    }

    .shopping-item-amount {
        grid-area: amount;
        text-align: left;
    }

    .shopping-delete {
        grid-area: delete;
        align-self: center;
    }

    .weekplan-item {
        height: auto;
        min-height: 4rem;
        padding: 8px 10px;
        align-items: flex-start;
        flex-direction: column;
    }

    .weekplan-actions {
        position: static;
        margin-top: 6px;
        margin-left: auto;
    }

    #addDialog {
        position: fixed;
        left: 10px !important;
        right: 10px !important;
        top: auto !important;
        bottom: 10px;
        width: auto;
        z-index: 25;
    }
}

@media (max-width: 640px) {
    body {
        padding: 20px 16px 28px;
    }

    nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 4px;
        gap: 10px;
    }

    nav::-webkit-scrollbar {
        height: 6px;
    }

    nav a {
        white-space: nowrap;
    }

    .log {
        max-height: 50vh;
    }

    .message {
        max-width: 92%;
    }

    .recipe.has-recipe {
        padding-top: 50px;
    }

    .save-recipe {
        top: 10px;
        right: 10px;
        padding: 7px 10px;
        font-size: 0.92rem;
    }

    .shopping-dialog {
        width: calc(100vw - 24px);
        padding: 14px;
    }

    #week {
        grid-template-columns: 1fr;
    }
}

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

.pixelate-page {
    display: grid;
    grid-template-columns: minmax(360px, 430px) minmax(0, 1fr) minmax(280px, 340px);
    gap: 22px;
}

.pixelate-page.page {
    max-width: none;
    width: calc(100vw - 48px);
}

.pixelate-panel,
.pixelate-preview-card,
.pixelate-legend-card {
    display: grid;
    gap: 22px;
    align-content: start;
}

.pixelate-panel > div:first-child,
.pixelate-preview-card > .pixelate-preview-head:first-child,
.pixelate-legend-card > .pixelate-preview-head:first-child {
    padding: 4px 6px 0;
}

.pixelate-panel h1,
.pixelate-preview-card h2,
.pixelate-legend-card h2 {
    margin: 0 0 10px;
}

.pixelate-copy,
.pixelate-meta {
    margin: 0;
    color: var(--muted);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    line-height: 1.6;
    font-size: 1rem;
}

.pixelate-dropzone {
    display: grid;
    place-items: center;
    gap: 12px;
    min-height: 240px;
    padding: 26px 22px;
    border-radius: 18px;
    border: 2px dashed rgba(231, 237, 244, 0.18);
    background:
        linear-gradient(135deg, rgba(255, 138, 102, 0.16), rgba(58, 209, 185, 0.08)),
        rgba(255, 255, 255, 0.04);
    text-align: center;
    cursor: pointer;
    transition: transform 160ms ease, border 160ms ease, box-shadow 160ms ease;
}

.pixelate-dropzone i {
    font-size: 2.4rem;
    color: var(--accent-2);
}

.pixelate-dropzone span {
    color: var(--muted);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    font-size: 1rem;
}

.pixelate-dropzone.is-dragover,
.pixelate-dropzone:hover {
    transform: translateY(-2px);
    border-color: rgba(58, 209, 185, 0.55);
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.35);
}

.pixelate-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.pixelate-controls label,
.pixelate-toggle {
    display: grid;
    gap: 8px;
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    color: var(--muted);
    font-size: 1rem;
}

.pixelate-controls input[type="number"] {
    width: 100%;
    min-height: 52px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
    font-size: 1rem;
}

.pixelate-toggle {
    grid-column: 1 / -1;
    grid-auto-flow: column;
    justify-content: start;
    align-items: center;
}

.pixelate-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.pixelate-actions .dialog-button {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 0 16px;
    width: 100%;
    font-size: 0.98rem;
}

.pixelate-actions #downloadButton {
    grid-column: 1 / -1;
}

.pixelate-actions .is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.pixelate-preview-head h2 {
    margin: 0;
}

.pixelate-legend-head {
    display: grid;
    gap: 12px;
}

.pixelate-legend-controls {
    display: grid;
    gap: 10px;
}

.pixelate-legend-controls label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.pixelate-legend-controls input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
}

.pixelate-legend-controls select {
    width: 100%;
    margin-top: 0;
}

.pixelate-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.pixelate-preview {
    margin: 0;
    display: grid;
    gap: 8px;
}

.pixelate-preview figcaption {
    color: var(--muted);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.pixelate-preview img {
    width: 100%;
    border-radius: 14px;
    border: 1px solid rgba(231, 237, 244, 0.1);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: var(--shadow);
    image-rendering: pixelated;
}

.pixelate-crop-stage {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    cursor: crosshair;
    user-select: none;
    touch-action: none;
}

.pixelate-crop-stage[data-crop-cursor="new"] {
    cursor: crosshair;
}

.pixelate-crop-stage[data-crop-cursor="move"] {
    cursor: grab;
}

.pixelate-crop-stage[data-crop-cursor="grabbing"] {
    cursor: grabbing;
}

.pixelate-crop-stage[data-crop-cursor="resize-n"],
.pixelate-crop-stage[data-crop-cursor="resize-s"] {
    cursor: ns-resize;
}

.pixelate-crop-stage[data-crop-cursor="resize-e"],
.pixelate-crop-stage[data-crop-cursor="resize-w"] {
    cursor: ew-resize;
}

.pixelate-crop-stage[data-crop-cursor="resize-ne"],
.pixelate-crop-stage[data-crop-cursor="resize-sw"] {
    cursor: nesw-resize;
}

.pixelate-crop-stage[data-crop-cursor="resize-nw"],
.pixelate-crop-stage[data-crop-cursor="resize-se"] {
    cursor: nwse-resize;
}

.pixelate-crop-stage img {
    display: block;
}

.pixelate-crop-selection {
    position: absolute;
    border: 2px solid rgba(58, 209, 185, 0.95);
    background: rgba(58, 209, 185, 0.12);
    pointer-events: none;
}

.pixelate-empty {
    min-height: 260px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    border: 1px dashed rgba(231, 237, 244, 0.16);
    color: var(--muted);
    font-style: italic;
    background: rgba(255, 255, 255, 0.03);
    padding: 24px;
    line-height: 1.6;
}

.pixelate-empty-compact {
    min-height: 140px;
}

.pixelate-summary {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(58, 209, 185, 0.22);
    background: rgba(58, 209, 185, 0.1);
    color: var(--ink);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.pixelate-legend-list {
    display: grid;
    gap: 10px;
}

.pixelate-busy-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 24px;
    background: color-mix(in srgb, var(--page-bg) 66%, transparent 34%);
    backdrop-filter: blur(5px);
}

.pixelate-busy-card {
    width: min(420px, calc(100vw - 32px));
    display: grid;
    gap: 10px;
    padding: 22px 24px;
    border-radius: 18px;
    border: 1px solid rgba(58, 209, 185, 0.24);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--card-strong) 96%, white 4%), color-mix(in srgb, var(--card) 98%, transparent 2%));
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
}

.pixelate-busy-card strong,
.pixelate-busy-card span {
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.pixelate-busy-card strong {
    color: var(--ink);
    font-size: 1.02rem;
}

.pixelate-busy-card span {
    color: var(--muted);
}

.pixelate-busy-bar {
    position: relative;
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: color-mix(in srgb, var(--card-muted) 82%, transparent 18%);
}

.pixelate-busy-bar-fill {
    position: absolute;
    inset: 0 auto 0 -35%;
    width: 35%;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(58, 209, 185, 0.3), rgba(255, 138, 102, 0.95), rgba(58, 209, 185, 0.3));
    animation: pixelate-busy-slide 1.1s ease-in-out infinite;
}

body.is-busy {
    cursor: progress;
}

@keyframes pixelate-busy-slide {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(390%);
    }
}

.pixelate-legend-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.05);
}

.pixelate-legend-swatch {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 1px solid rgba(231, 237, 244, 0.22);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.16);
}

.pixelate-legend-meta {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.pixelate-legend-meta strong,
.pixelate-legend-meta span {
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.pixelate-legend-meta span {
    color: var(--muted);
    line-height: 1.5;
}

.pixelate-legend-stock {
    display: inline-grid;
    grid-template-columns: auto 1fr;
    width: fit-content;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 16px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.06);
    margin-top: 2px;
}

.pixelate-legend-stock > i {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.76rem;
    background: rgba(255, 255, 255, 0.18);
}

.pixelate-legend-stock-copy {
    display: grid;
    gap: 2px;
    line-height: 1.2;
}

.pixelate-legend-stock-copy span:first-child {
    font-weight: 600;
}

.pixelate-legend-stock-copy span:last-child {
    font-size: 0.82rem;
    color: inherit;
    opacity: 0.86;
}

.pixelate-legend-stock.is-owned {
    color: #bff6dc;
    border-color: rgba(58, 209, 185, 0.34);
    background: rgba(58, 209, 185, 0.12);
}

.pixelate-legend-stock.is-partial {
    color: #ffe0b3;
    border-color: rgba(255, 184, 82, 0.34);
    background: rgba(255, 184, 82, 0.12);
}

.pixelate-legend-stock.is-missing {
    color: #ffbbb1;
    border-color: rgba(255, 138, 102, 0.34);
    background: rgba(255, 138, 102, 0.12);
}

html[data-theme="light"] .pixelate-legend-stock {
    background: rgba(255, 255, 255, 0.6);
}

html[data-theme="light"] .pixelate-legend-stock > i {
    background: rgba(255, 255, 255, 0.9);
}

.pattern-page {
    display: grid;
    grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
    gap: 18px;
}

.pattern-sidebar {
    position: sticky;
    top: 12px;
}

.pattern-page.page {
    max-width: none;
    width: calc(100vw - 48px);
    min-height: calc(100vh - 140px);
}

.thread-color-page {
    display: grid;
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr) minmax(290px, 360px);
    gap: 18px;
    align-items: start;
}

.thread-color-result-card {
    position: sticky;
    top: 12px;
}

.thread-color-page.page {
    max-width: none;
    width: calc(100vw - 48px);
}

.statistics-page {
    display: grid;
    gap: 18px;
    align-content: start;
    max-width: none;
    width: calc(100vw - 48px);
}

.statistics-intro,
.statistics-chart-card,
.statistics-patterns-card,
.statistics-kpi-card {
    display: grid;
    gap: 12px;
    align-content: start;
}

.statistics-timezone {
    color: var(--muted);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.statistics-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.statistics-kpi-card {
    padding: 14px;
    border-radius: 14px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.05);
}

.statistics-kpi-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.statistics-kpi-icon {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(58, 209, 185, 0.3);
    background: rgba(58, 209, 185, 0.15);
}

.statistics-kpi-grid {
    display: grid;
    gap: 6px;
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.statistics-kpi-grid span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
}

.statistics-chart-wrap {
    min-height: 320px;
}

.statistics-table-wrap {
    overflow-x: auto;
}

.statistics-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 780px;
}

.statistics-table th,
.statistics-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(231, 237, 244, 0.1);
    vertical-align: top;
}

.statistics-table td small {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
}

.statistics-cell-main {
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.thread-color-intro,
.thread-color-photo-card,
.thread-color-result-card,
.thread-color-palette-card {
    display: grid;
    gap: 16px;
    align-content: start;
}

.thread-color-palette-card {
    grid-column: 1 / -1;
}

.thread-color-methods {
    display: grid;
    gap: 12px;
}

.thread-color-method-card {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.05);
}

.thread-color-method-card h2,
.thread-color-method-card p,
.thread-palette-header h2 {
    margin: 0;
}

.thread-color-method-card h2::before {
    content: "• ";
    color: var(--accent-2);
}

.thread-color-method-card p {
    margin-top: 6px;
    color: var(--muted);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.thread-photo-meta {
    min-height: 68px;
    align-content: start;
}

.thread-preview-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(220px, 0.75fr);
    gap: 16px;
}

.thread-crop-stage {
    min-height: 260px;
}

.thread-crop-stage img {
    width: 100%;
    display: block;
}

.thread-sample-card {
    min-height: 100%;
    display: grid;
    gap: 14px;
    align-content: start;
    padding: 18px;
    border-radius: 16px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: var(--shadow);
}

.thread-sample-swatch {
    width: 100%;
    min-height: 180px;
    border-radius: 16px;
    border: 1px solid rgba(231, 237, 244, 0.16);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.thread-sample-card strong,
.thread-sample-card span,
.thread-best-match-meta span,
.thread-best-match-meta strong,
.thread-match-meta strong,
.thread-match-meta span,
.thread-palette-search,
.thread-palette-card strong,
.thread-palette-card span {
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.thread-sample-card span,
.thread-best-match-meta span,
.thread-match-meta span,
.thread-palette-card span {
    color: var(--muted);
}

.thread-best-match {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 14px;
    align-items: center;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid rgba(58, 209, 185, 0.22);
    background: rgba(58, 209, 185, 0.08);
}

.thread-best-match-swatch {
    width: 92px;
    height: 92px;
    border-radius: 18px;
    border: 1px solid rgba(231, 237, 244, 0.16);
}

.thread-best-match-meta,
.thread-match-meta {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.thread-result-notice {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 184, 82, 0.26);
    background: rgba(255, 184, 82, 0.1);
    color: var(--ink);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.thread-toast {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1300;
    min-width: 240px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(17, 24, 34, 0.96);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.38);
    color: var(--ink);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.thread-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.thread-toast.is-success {
    border-color: rgba(58, 209, 185, 0.34);
    background: rgba(20, 38, 37, 0.96);
}

.thread-toast.is-error {
    border-color: rgba(255, 138, 102, 0.34);
    background: rgba(46, 24, 21, 0.96);
}

.thread-result-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.78rem;
}

.thread-match-list {
    display: grid;
    gap: 10px;
}

.thread-color-result-card .pixelate-empty {
    text-align: center;
}

.thread-match-item {
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.04);
}

.thread-match-rank {
    width: 24px;
    text-align: center;
    color: var(--muted);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.thread-match-swatch {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 1px solid rgba(231, 237, 244, 0.16);
}

.thread-palette-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
    gap: 16px;
    align-items: end;
}

.thread-palette-search {
    display: grid;
    gap: 6px;
    color: var(--muted);
}

.thread-palette-search input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
}

.thread-palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.thread-palette-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.04);
    align-content: start;
}

.thread-palette-meta {
    display: grid;
    gap: 6px;
    min-height: 64px;
    align-content: start;
}

.thread-palette-meta strong {
    line-height: 1.15;
}

.thread-palette-meta span {
    line-height: 1.25;
}

.thread-palette-swatch {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 16px;
    border: 1px solid rgba(231, 237, 244, 0.16);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14);
}

.thread-stock-state {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.06);
}

.thread-palette-stock-row {
    display: grid;
    gap: 10px;
    align-content: start;
}

.thread-stock-state.is-owned {
    color: #bff6dc;
    border-color: rgba(58, 209, 185, 0.34);
    background: rgba(58, 209, 185, 0.12);
}

.thread-stock-state.is-missing {
    color: #ffbbb1;
    border-color: rgba(255, 138, 102, 0.34);
    background: rgba(255, 138, 102, 0.12);
}

.thread-stock-editor {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: end;
}

.thread-best-match .thread-stock-editor {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
}

.thread-best-match .thread-stock-save {
    justify-self: start;
}

.thread-stock-editor label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.thread-stock-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
}

.thread-stock-save {
    min-width: 132px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.thread-palette-card .thread-stock-editor {
    grid-template-columns: 1fr;
    align-items: stretch;
}

.thread-palette-card .thread-stock-input {
    text-align: center;
}

.thread-stock-editor-compact {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.thread-palette-card .thread-stock-editor-compact {
    grid-template-columns: minmax(0, 1fr) auto;
}

.thread-stock-icon-save {
    width: 42px;
    height: 42px;
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.thread-best-match:hover .thread-stock-save,
.thread-best-match:focus-within .thread-stock-save,
.thread-palette-card:hover .thread-stock-icon-save,
.thread-palette-card:focus-within .thread-stock-icon-save {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.pattern-sidebar,
.pattern-viewer {
    display: grid;
    gap: 14px;
    align-content: start;
    min-height: 0;
}

.pattern-sidebar h1,
.pattern-header h2 {
    margin: 0;
}

.pattern-header {
    display: grid;
    gap: 12px;
}

.pattern-header > div:first-child {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
    grid-template-areas:
        "title progress"
        "meta progress";
    align-items: start;
    gap: 8px 24px;
    padding-right: 0;
}

.pattern-header > div:first-child h2 {
    grid-area: title;
}

.pattern-header > div:first-child .pixelate-copy {
    grid-area: meta;
}

.pattern-toolbar {
    display: grid;
    grid-template-columns: auto auto;
    align-items: center;
    gap: 10px;
    justify-content: start;
}

.pattern-progress-panel {
    display: grid;
    gap: 10px;
    margin-top: 0;
    grid-area: progress;
    width: 100%;
    max-width: 420px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
        rgba(12, 16, 24, 0.52);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.18);
}

.pattern-progress-topline {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}

.pattern-progress-form {
    display: grid;
    grid-template-columns: minmax(0, 110px) auto;
    align-items: stretch;
    gap: 8px;
    justify-content: start;
}

.pattern-progress-input-wrap input {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.pattern-progress-input-wrap input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.pattern-progress-bar {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(231, 237, 244, 0.1);
}

.pattern-progress-bar-fill {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #3ad1b9 0%, #ff8a66 100%);
    transition: width 180ms ease;
}

html[data-theme="light"] .pattern-progress-panel {
    border-color: rgba(205, 188, 168, 0.42);
    background:
        linear-gradient(180deg, rgba(255, 250, 243, 0.96), rgba(246, 239, 229, 0.94)),
        rgba(255, 255, 255, 0.92);
    box-shadow: 0 16px 34px rgba(181, 148, 110, 0.18);
}

html[data-theme="light"] .pattern-progress-panel strong {
    color: #3d342d;
}

html[data-theme="light"] .pattern-progress-input-wrap input {
    border-color: rgba(196, 183, 168, 0.7);
    background: rgba(255, 255, 255, 0.82);
    color: #3f372f;
}

html[data-theme="light"] .pattern-progress-input-wrap input::placeholder {
    color: #978b80;
}

html[data-theme="light"] .pattern-progress-bar {
    background: rgba(214, 203, 189, 0.72);
    border-color: rgba(198, 185, 169, 0.76);
}

.pattern-zoom-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.pattern-zoom-label {
    min-width: 52px;
    text-align: center;
    color: var(--ink);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.pattern-hover-info {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: var(--ink);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    min-height: 44px;
    display: flex;
    align-items: center;
    min-width: 320px;
    max-width: 460px;
}

.pattern-list {
    display: grid;
    gap: 10px;
}

.pattern-list-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: stretch;
    border-radius: 14px;
    transition: background 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.pattern-list-item.is-active {
    background: rgba(58, 209, 185, 0.08);
    box-shadow: inset 0 0 0 1px rgba(58, 209, 185, 0.18);
}

.pattern-list-progress-text {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
}

.pattern-open-button {
    min-width: 0;
}

.pattern-delete-button {
    width: 42px;
    min-width: 42px;
    border-radius: 12px;
    border: 1px solid rgba(255, 138, 102, 0.26);
    background: rgba(255, 138, 102, 0.16);
    color: color-mix(in srgb, var(--accent) 72%, #7c2213 28%);
    cursor: pointer;
    transition: transform 140ms ease, background 140ms ease, border 140ms ease;
}

.pattern-delete-button:hover {
    transform: translateY(-1px);
    background: rgba(255, 138, 102, 0.28);
    border-color: rgba(255, 138, 102, 0.42);
}

html[data-theme="light"] .pattern-delete-button {
    background: rgba(221, 110, 66, 0.12);
    border-color: rgba(221, 110, 66, 0.2);
    color: #b14d28;
}

.pattern-list .project-item span {
    color: var(--muted);
    font-size: 0.9rem;
}

.pattern-content {
    display: grid;
    gap: 16px;
    min-height: 0;
}

.pattern-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.9fr) minmax(220px, 280px);
    gap: 16px;
    align-items: start;
    min-height: 0;
}

.pattern-sidepanel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px;
    align-content: start;
    min-height: 0;
}

.pattern-minimap-card {
    display: grid;
    gap: 10px;
}

.pattern-minimap-head h3 {
    margin: 0;
    font-size: 1rem;
}

.pattern-minimap-wrap {
    position: relative;
    width: fit-content;
    max-width: 100%;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.04);
    cursor: crosshair;
}

.pattern-minimap-wrap canvas {
    display: block;
    image-rendering: pixelated;
}

.pattern-minimap-viewport {
    position: absolute;
    border: 2px solid rgba(255, 138, 102, 0.95);
    background: rgba(255, 138, 102, 0.12);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    pointer-events: none;
}

.pattern-canvas-wrap {
    overflow: auto;
    min-height: 0;
    max-height: calc(100vh - 270px);
    padding: 12px;
    border-radius: 16px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.04);
}

.pattern-canvas-wrap canvas {
    display: block;
    image-rendering: pixelated;
}

.pattern-sidepanel .pixelate-legend-list {
    min-height: 0;
    max-height: calc(100vh - 430px);
    overflow: auto;
    padding-right: 4px;
}

.pattern-canvas-wrap,
.pattern-sidepanel .pixelate-legend-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(58, 209, 185, 0.5) rgba(255, 255, 255, 0.04);
}

.pattern-canvas-wrap::-webkit-scrollbar,
.pattern-sidepanel .pixelate-legend-list::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.pattern-canvas-wrap::-webkit-scrollbar-track,
.pattern-sidepanel .pixelate-legend-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 999px;
}

.pattern-canvas-wrap::-webkit-scrollbar-thumb,
.pattern-sidepanel .pixelate-legend-list::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(58, 209, 185, 0.8), rgba(255, 138, 102, 0.8));
    border-radius: 999px;
    border: 2px solid rgba(17, 24, 32, 0.45);
}

.pattern-canvas-wrap::-webkit-scrollbar-thumb:hover,
.pattern-sidepanel .pixelate-legend-list::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(58, 209, 185, 1), rgba(255, 138, 102, 1));
}

.project-sidebar {
    display: grid;
    gap: 18px;
}

.project-main {
    min-width: 0;
    display: grid;
    gap: 12px;
}

.project-card {
    background: var(--card);
    border-radius: 16px;
    padding: 16px;
    border: 1px solid rgba(231, 237, 244, 0.1);
    box-shadow: var(--shadow);
}

.project-card h1,
.project-card h2,
.project-card h3 {
    margin: 0 0 12px 0;
}

.project-create,
.task-create {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-bottom: 12px;
}

.project-create input,
.task-create input,
.task-title {
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.project-list {
    display: grid;
    gap: 8px;
}

.project-item {
    position: relative;
    text-align: left;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
    cursor: pointer;
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.project-item.is-active {
    border-color: rgba(58, 209, 185, 0.72);
    background: linear-gradient(135deg, rgba(58, 209, 185, 0.2), rgba(255, 138, 102, 0.12));
    box-shadow: 0 0 0 1px rgba(58, 209, 185, 0.18), 0 12px 24px rgba(14, 25, 34, 0.2);
    transform: translateY(-1px);
}

.project-item.is-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 4px;
    border-radius: 999px;
    background: linear-gradient(180deg, #3ad1b9 0%, #ff8a66 100%);
}

.project-item.is-active strong {
    color: #f4fffd;
}

.project-item.is-active .pattern-list-progress-text,
.project-item.is-active span {
    color: rgba(233, 247, 245, 0.9);
}

html[data-theme="light"] .pattern-list-item.is-active {
    background: rgba(58, 209, 185, 0.08);
    box-shadow: inset 0 0 0 1px rgba(58, 209, 185, 0.22);
}

html[data-theme="light"] .project-item.is-active {
    border-color: rgba(58, 209, 185, 0.72);
    background: linear-gradient(135deg, rgba(58, 209, 185, 0.12), rgba(255, 138, 102, 0.08));
    box-shadow: 0 0 0 1px rgba(58, 209, 185, 0.16), 0 10px 20px rgba(140, 108, 77, 0.12);
}

html[data-theme="light"] .project-item.is-active strong {
    color: #2a2a2a;
}

html[data-theme="light"] .project-item.is-active span,
html[data-theme="light"] .project-item.is-active .pattern-list-progress-text {
    color: #5f584f;
}

.project-empty {
    margin: 0;
    color: var(--muted);
    font-style: italic;
}

.calendar-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.calendar-head h2 {
    text-align: center;
    margin: 0;
    text-transform: capitalize;
}

.project-view-switch {
    padding: 12px;
}

.project-view-buttons {
    display: inline-grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.project-view-buttons .dialog-button {
    min-width: 120px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.calendar-weekday {
    text-align: center;
    color: var(--muted);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.calendar-cell {
    min-height: 110px;
    border-radius: 12px;
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.04);
    padding: 8px;
    display: grid;
    gap: 6px;
    align-content: start;
}

.calendar-cell.is-empty {
    opacity: 0.3;
    min-height: 60px;
}

.calendar-event {
    font-size: 0.8rem;
    padding: 4px 6px;
    border-radius: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.calendar-event.deadline {
    background: rgba(255, 138, 102, 0.2);
    border: 1px solid rgba(255, 138, 102, 0.32);
}

.calendar-event.milestone {
    background: rgba(58, 209, 185, 0.2);
    border: 1px solid rgba(58, 209, 185, 0.34);
}

.kanban-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.kanban-head h2 {
    margin: 0;
}

.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(200px, 1fr));
    gap: 12px;
    overflow-x: auto;
}

.kanban-column {
    background: rgba(11, 16, 22, 0.5);
    border: 1px solid rgba(231, 237, 244, 0.12);
    border-radius: 14px;
    padding: 10px;
    min-height: 220px;
}

.kanban-column[data-status="ideas"] {
    background: rgba(188, 146, 255, 0.14);
    border-color: rgba(188, 146, 255, 0.34);
}

.kanban-column[data-status="todo"] {
    background: rgba(255, 138, 102, 0.14);
    border-color: rgba(255, 138, 102, 0.34);
}

.kanban-column[data-status="in_progress"] {
    background: rgba(126, 166, 255, 0.14);
    border-color: rgba(126, 166, 255, 0.34);
}

.kanban-column[data-status="finished"] {
    background: rgba(58, 209, 185, 0.14);
    border-color: rgba(58, 209, 185, 0.34);
}

.kanban-column h3 {
    margin: 0 0 10px 0;
    font-size: 1rem;
}

.kanban-list {
    min-height: 150px;
    display: grid;
    gap: 10px;
    align-content: start;
    border-radius: 10px;
    transition: background 120ms ease;
}

.kanban-list.is-over {
    background: rgba(58, 209, 185, 0.1);
}

.task-card {
    border: 1px solid rgba(231, 237, 244, 0.12);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 8px;
    display: grid;
    gap: 8px;
    cursor: grab;
}

.task-card.is-dragging {
    opacity: 0.45;
}

.task-meta {
    display: grid;
    gap: 6px;
}

.task-topline {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
}

.task-meta input[type="date"] {
    width: 100%;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: var(--ink);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.task-deadline {
    font-size: 0.82rem;
    color: var(--muted);
}

.task-deadline-toggle {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid rgba(231, 237, 244, 0.14);
    background: rgba(126, 166, 255, 0.16);
    color: var(--ink);
    cursor: pointer;
    transition: transform 140ms ease, background 140ms ease, border 140ms ease;
}

.task-deadline-toggle:hover {
    transform: translateY(-1px);
    background: rgba(126, 166, 255, 0.28);
    border-color: rgba(126, 166, 255, 0.4);
}

.task-deadline-editor {
    display: grid;
}

.task-deadline-editor[hidden] {
    display: none;
}

.task-milestone {
    font-size: 0.82rem;
    color: var(--muted);
}

@media (max-width: 1180px) {
    .project-page {
        grid-template-columns: 1fr;
    }

    .pixelate-page {
        grid-template-columns: 1fr;
    }

    .thread-color-page {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .thread-palette-header,
    .thread-preview-grid {
        grid-template-columns: 1fr;
    }

    .pattern-page {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .pattern-layout {
        grid-template-columns: 1fr;
    }

    .pattern-toolbar {
        grid-template-columns: 1fr;
    }

    .pattern-header > div:first-child {
        grid-template-columns: 1fr;
        grid-template-areas:
            "title"
            "meta"
            "progress";
    }

    .pattern-progress-panel {
        width: 100%;
        margin-top: 4px;
        max-width: none;
    }

    .pattern-progress-topline {
        grid-template-columns: 1fr;
    }

    .pattern-progress-form {
        grid-template-columns: 1fr;
    }

    .pattern-hover-info {
        min-width: 0;
        max-width: none;
    }

    .pattern-canvas-wrap,
    .pattern-sidepanel .pixelate-legend-list {
        max-height: none;
    }

    .calendar-cell {
        min-height: 100px;
    }
}

@media (max-width: 760px) {
    .project-create,
    .task-create {
        grid-template-columns: 1fr;
    }

    .kanban-head {
        flex-direction: column;
        align-items: stretch;
    }

    .kanban-board {
        grid-template-columns: repeat(4, minmax(240px, 1fr));
    }

    .pixelate-controls,
    .pixelate-preview-grid {
        grid-template-columns: 1fr;
    }

    .thread-color-methods,
    .thread-palette-grid {
        grid-template-columns: 1fr;
    }

    .thread-best-match {
        grid-template-columns: 1fr;
    }

    .thread-stock-editor {
        grid-template-columns: 1fr;
    }
}

html[data-theme="dark"] {
    --ink: #f4efe8;
    --muted: #c2b8ad;
    --accent: #ff7e5f;
    --accent-2: #31c7b0;
    --accent-soft: rgba(255, 126, 95, 0.18);
    --accent-2-soft: rgba(49, 199, 176, 0.18);
    --card: rgba(18, 22, 28, 0.78);
    --card-strong: rgba(28, 33, 42, 0.9);
    --card-muted: rgba(255, 255, 255, 0.06);
    --line: rgba(255, 244, 230, 0.12);
    --page-bg: #0c0f13;
    --page-bg-2: #151b23;
    --shadow: 0 20px 55px rgba(0, 0, 0, 0.34);
    --shadow-hover: 0 26px 65px rgba(0, 0, 0, 0.42);
    --signal-bg: rgba(49, 199, 176, 0.18);
    --signal-border: rgba(49, 199, 176, 0.42);
    --signal-ink: #6fe0ce;
}

html[data-theme="light"] {
    --ink: #2f2a28;
    --muted: #756a63;
    --accent: #dd6e42;
    --accent-2: #178d82;
    --accent-soft: rgba(221, 110, 66, 0.12);
    --accent-2-soft: rgba(23, 141, 130, 0.14);
    --card: rgba(255, 250, 244, 0.82);
    --card-strong: rgba(255, 246, 237, 0.94);
    --card-muted: rgba(78, 54, 41, 0.05);
    --line: rgba(90, 64, 52, 0.12);
    --page-bg: #f7efe7;
    --page-bg-2: #fffaf4;
    --shadow: 0 20px 40px rgba(175, 122, 87, 0.12);
    --shadow-hover: 0 24px 48px rgba(175, 122, 87, 0.18);
    --signal-bg: rgba(23, 141, 130, 0.12);
    --signal-border: rgba(23, 141, 130, 0.3);
    --signal-ink: #177d74;
}

:root {
    --font-family-body: "Manrope", "Segoe UI", sans-serif;
    --font-family-heading: "Cormorant Garamond", "Georgia", serif;
    --font-family-ui: "Space Grotesk", "Segoe UI", sans-serif;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 28px;

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-pill: 999px;

    --motion-fast: 140ms ease;
    --motion-base: 180ms ease;
    --motion-slow: 260ms ease;

    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent-2) 36%, transparent 64%);

    --component-bg: var(--card-muted);
    --component-bg-hover: color-mix(in srgb, var(--card-muted) 80%, white 20%);
    --component-border: var(--line);
    --component-border-strong: color-mix(in srgb, var(--line) 60%, var(--ink) 40%);

    --card-padding: 28px;
    --card-padding-mobile: 18px;
    --card-gap: 22px;
    --card-header-gap: 12px;
}

html:not([data-theme]) {
    color-scheme: dark;
}

html[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="light"] {
    color-scheme: light;
}

body {
    font-family: var(--font-family-body);
    padding: 24px 24px 52px;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, var(--accent-soft), transparent 28%),
        radial-gradient(circle at 85% 15%, var(--accent-2-soft), transparent 24%),
        linear-gradient(180deg, var(--page-bg-2) 0%, var(--page-bg) 100%);
    position: relative;
    overflow-x: hidden;
}

body::before,
body::after {
    content: "";
    position: fixed;
    pointer-events: none;
    z-index: -1;
}

body::before {
    top: 60px;
    right: -90px;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-soft) 0%, transparent 68%);
    filter: blur(8px);
}

body::after {
    left: -80px;
    bottom: 40px;
    width: 360px;
    height: 360px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-2-soft) 0%, transparent 70%);
    filter: blur(10px);
}

.site-header {
    max-width: 1300px;
    margin: 0 auto 22px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "brand nav auth controls";
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-radius: 28px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    position: relative;
    z-index: 200;
}

.site-brand {
    grid-area: brand;
}

.site-brand-link {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: var(--ink);
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.02)),
        linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 14px 24px rgba(0, 0, 0, 0.14);
}

.brand-copy {
    display: grid;
    gap: 2px;
}

.brand-copy strong,
.home-hero h1,
.workflow-card h2,
.stitch-feature-card strong,
.page h1,
.pattern-header h2,
.thread-color-method-card h2,
.thread-palette-header h2 {
    font-family: "Cormorant Garamond", "Georgia", serif;
}

.brand-copy strong {
    font-size: 1.05rem;
    letter-spacing: 0.04em;
}

.brand-copy span {
    font-size: 0.8rem;
    color: var(--muted);
}

.site-nav {
    grid-area: nav;
    justify-content: center;
    align-items: center;
    margin: 0;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
}

.site-nav-link,
.site-nav-trigger {
    min-height: 42px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--component-border);
    background: color-mix(in srgb, var(--component-bg) 84%, transparent 16%);
    color: var(--ink);
    font-family: var(--font-family-ui);
    font-size: 0.92rem;
    line-height: 1;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    text-decoration: none;
}

.site-nav-group {
    position: relative;
    z-index: 1;
}

.site-nav-trigger {
    cursor: pointer;
}

.site-nav-group.is-current .site-nav-trigger,
.site-nav-link.current,
.site-nav-sub-link.current {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.16);
}

.site-nav-group.is-current .site-nav-trigger {
    position: relative;
}

.site-nav-group.is-current .site-nav-trigger::after,
.site-nav-link.current::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 6px;
    height: 2px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.88);
}

.site-nav-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    padding: 8px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--page-bg-2) 96%, var(--card-strong) 4%);
    box-shadow: var(--shadow);
    display: grid;
    gap: 6px;
    opacity: 0;
    transform: translateY(8px) scale(0.98);
    visibility: hidden;
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
    z-index: 1200;
}

.site-nav-group.is-open .site-nav-dropdown {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
    pointer-events: auto;
}

.site-nav-sub-link,
.site-nav-sub-button {
    min-height: 38px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink);
    font-family: var(--font-family-ui);
    font-size: 0.9rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 0 10px;
    cursor: pointer;
}

.site-nav-sub-link,
.site-nav-sub-button,
.site-nav-link,
.site-nav-trigger {
    transition: background var(--motion-fast), border-color var(--motion-fast), transform var(--motion-fast), box-shadow var(--motion-fast);
}

.site-nav-link:hover,
.site-nav-trigger:hover,
.site-nav-sub-link:hover,
.site-nav-sub-button:hover:not([disabled]) {
    background: var(--component-bg-hover);
    border-color: var(--component-border-strong);
}

.site-nav-sub-link:hover,
.site-nav-sub-button:hover:not([disabled]) {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--line);
}

.site-nav-sub-button[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

.site-nav a,
.auth-chip,
.auth-link,
.auth-logout,
.locale-toggle,
.theme-toggle {
    min-height: 42px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--component-border);
    background: color-mix(in srgb, var(--component-bg) 84%, transparent 16%);
    color: var(--ink);
    font-family: var(--font-family-ui);
    font-size: 0.92rem;
    line-height: 1;
    box-shadow: none;
    white-space: nowrap;
}

.site-nav a,
.auth-link,
.auth-logout,
.locale-toggle,
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
}

.header-controls {
    grid-area: controls;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.global-utility-panel {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 100;
}

.global-utility-panel .header-controls {
    display: inline-flex;
    gap: 8px;
    padding: 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

body.has-global-utility-panel {
    padding-top: 78px;
}

.theme-toggle {
    cursor: pointer;
    width: fit-content;
    max-width: max-content;
    flex: 0 0 auto;
    justify-self: end;
    transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.locale-toggle {
    font-weight: 600;
    width: fit-content;
    max-width: max-content;
    cursor: pointer;
    transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.locale-toggle:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    background: rgba(255, 255, 255, 0.12);
}

.theme-toggle:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    background: rgba(255, 255, 255, 0.12);
}

.auth-nav {
    grid-area: auth;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
}

.auth-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    min-width: 0;
}

.auth-chip span {
    display: inline-block;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-link,
.auth-logout {
    font-weight: 500;
}

nav a,
.theme-toggle,
.locale-toggle,
.dialog-button,
.project-item,
.pattern-delete-button,
.thread-palette-card,
.thread-match-item,
.workflow-card,
.stitch-feature-card,
.pixelate-panel,
.pixelate-preview-card,
.pixelate-legend-card,
.thread-color-intro,
.thread-color-photo-card,
.thread-color-result-card,
.thread-color-palette-card,
.pattern-sidebar,
.pattern-viewer,
.pattern-minimap-card {
    transition: transform var(--motion-base), box-shadow var(--motion-base), background var(--motion-base), border-color var(--motion-base);
}

button,
input,
select,
textarea {
    font-family: var(--font-family-ui);
}

input,
select,
textarea {
    border-radius: var(--radius-sm);
    border: 1px solid var(--component-border);
    background: var(--component-bg);
    color: var(--ink);
    transition: border-color var(--motion-fast), box-shadow var(--motion-fast), background var(--motion-fast);
}

input:hover,
select:hover,
textarea:hover {
    border-color: var(--component-border-strong);
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.dialog-button,
.icon-button {
    border-radius: var(--radius-md);
    border: 1px solid var(--component-border);
    transition: transform var(--motion-fast), background var(--motion-fast), box-shadow var(--motion-fast), border-color var(--motion-fast);
}

.card,
.panel {
    border-radius: var(--radius-lg);
    border: 1px solid var(--component-border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)), var(--card);
    box-shadow: var(--shadow);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 26px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--component-border);
    background: var(--component-bg);
    color: var(--ink);
    font-family: var(--font-family-ui);
    font-size: 0.82rem;
    line-height: 1;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--component-border);
}

.empty-state {
    border-radius: var(--radius-md);
    border: 1px dashed var(--component-border);
    background: color-mix(in srgb, var(--component-bg) 78%, transparent 22%);
    color: var(--muted);
    font-family: var(--font-family-ui);
    padding: var(--space-4);
}

.page,
.pixelate-panel,
.pixelate-preview-card,
.pixelate-legend-card,
.thread-color-intro,
.thread-color-photo-card,
.thread-color-result-card,
.thread-color-palette-card,
.pattern-sidebar,
.pattern-viewer,
.pattern-minimap-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)), var(--card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
    padding: var(--card-padding);
}

.page {
    border-radius: 30px;
}

nav a {
    font-weight: 500;
}

nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--line);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
}

nav a.current {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.16);
}

.dialog-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    border-color: transparent;
}

.dialog-primary:hover {
    background: linear-gradient(135deg, #ef7b55, #1fbaa4);
}

.dialog-ghost {
    background: var(--card-muted);
    border-color: var(--line);
}

.home-page {
    max-width: 1300px;
    margin: 0 auto;
    display: grid;
    gap: 20px;
}

.login-page {
    max-width: 820px;
    margin: 0 auto;
}

.account-page {
    max-width: 980px;
    margin: 0 auto;
}

.admin-page {
    max-width: 1200px;
    margin: 0 auto;
}

.forum-page {
    max-width: 1200px;
    margin: 0 auto;
}

.forum-panel {
    display: grid;
    gap: var(--card-gap);
}

.forum-card {
    border-radius: 24px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
    padding: 18px;
    display: grid;
    gap: 12px;
}

.forum-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.forum-search-row {
    flex-wrap: wrap;
}

.forum-head-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.forum-head {
    display: grid;
    gap: 8px;
    padding-bottom: 2px;
}

.forum-search-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.forum-search-form input {
    min-height: 42px;
    min-width: 260px;
    padding: 0 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--card-muted);
    color: var(--ink);
}

.forum-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.forum-category-pill {
    border: 1px solid var(--line);
    border-radius: 999px;
    min-height: 36px;
    padding: 0 14px;
    background: var(--card-muted);
    color: var(--ink);
    cursor: pointer;
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    font-weight: 600;
}

.forum-category-pill.is-active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
    color: #fff;
}

.forum-threads,
.forum-post-list,
.forum-notification-list {
    display: grid;
    gap: 10px;
}

.forum-thread-item,
.forum-post-item,
.forum-notification-item {
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--card-muted);
    padding: 12px;
}

.forum-thread-item,
.forum-post-item,
.forum-notification-item,
.forum-card,
.account-card,
.admin-card {
    transition: transform var(--motion-fast), box-shadow var(--motion-fast), border-color var(--motion-fast), background var(--motion-fast);
}

.forum-thread-item:hover,
.forum-post-item:hover,
.forum-notification-item:hover {
    transform: translateY(-1px);
    border-color: var(--component-border-strong);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
}

.forum-thread-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
}

.forum-thread-main {
    display: grid;
    gap: 8px;
}

.forum-thread-item h3 {
    margin: 0;
}

.forum-thread-starter {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card-muted);
    padding: 12px 14px;
}

.forum-thread-starter .pixelate-copy {
    margin: 0;
}

.forum-post-item p {
    margin: 4px 0 14px;
    line-height: 1.55;
}

.forum-thread-meta,
.forum-post-head,
.forum-post-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.92rem;
}

.forum-thread-author {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.forum-thread-author-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    color: var(--muted);
    font-size: 0.78rem;
    padding: 0 8px;
    line-height: 1.8;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: max-width .18s ease, opacity .18s ease;
}

.forum-thread-author:hover .forum-thread-author-tag,
.forum-thread-author:focus-within .forum-thread-author-tag {
    max-width: 220px;
    opacity: 1;
}

.forum-thread-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

.forum-like-button.is-liked {
    border-color: color-mix(in srgb, var(--accent) 46%, var(--line));
    color: color-mix(in srgb, var(--accent) 75%, var(--ink));
}

.forum-like-button.is-liked i {
    color: color-mix(in srgb, var(--accent) 84%, var(--ink));
}

.forum-notification-item.is-unread {
    border-color: rgba(49, 199, 176, 0.42);
    box-shadow: inset 0 0 0 1px rgba(49, 199, 176, 0.2);
}

.forum-composer textarea,
.forum-composer select {
    width: 100%;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--card-muted);
    color: var(--ink);
    font: inherit;
    padding: 12px 14px;
}

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

.forum-selected-share {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card-muted);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.forum-selected-share-main {
    display: grid;
    gap: 4px;
}

.forum-selected-share-main strong {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.forum-project-share-card {
    margin: 10px 0 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--card-strong) 92%, transparent 8%);
    padding: 10px;
    display: grid;
    gap: 10px;
}

.forum-project-share-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.forum-project-share-head strong {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.forum-project-share-fabric {
    color: var(--muted);
    font-size: 0.85rem;
}

.forum-project-share-visuals {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
}

.forum-project-share-visuals.has-private {
    grid-template-columns: minmax(0, 1fr) minmax(140px, 220px);
}

.forum-project-share-figure {
    margin: 0;
    display: grid;
    gap: 6px;
}

.forum-project-share-figure figcaption {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.forum-project-share-figure img {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--card);
    display: block;
}

.forum-project-share-figure-reference img {
    max-height: 160px;
    object-fit: contain;
}

.forum-project-share-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.88rem;
}

.forum-mention-input-wrap {
    position: relative;
}

.forum-mention-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 8px);
    z-index: 40;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--card-strong) 96%, black 4%);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
    display: grid;
    gap: 4px;
    padding: 8px;
    max-height: 260px;
    overflow: auto;
}

.forum-mention-option {
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
    min-height: 42px;
    width: 100%;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    text-align: left;
    cursor: pointer;
}

.forum-mention-option:hover,
.forum-mention-option.is-active {
    background: var(--card-muted);
    border-color: rgba(49, 199, 176, 0.35);
}

.forum-mention-option-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.forum-mention-option-main strong {
    font-size: 0.95rem;
}

.forum-mention-option-tag {
    color: var(--muted);
    font-size: 0.86rem;
}

.forum-mention-option-badge {
    border-radius: 999px;
    border: 1px solid rgba(49, 199, 176, 0.35);
    padding: 2px 8px;
    color: var(--accent);
    font-size: 0.75rem;
    white-space: nowrap;
}

.forum-mention-empty {
    color: var(--muted);
    font-size: 0.9rem;
    padding: 8px 10px;
}

.forum-mention-highlight {
    display: inline-block;
    padding: 0 6px;
    border-radius: 999px;
    border: 1px solid var(--signal-border);
    background: var(--signal-bg);
    color: var(--signal-ink);
    font-weight: 700;
}

.forum-modal {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 0;
    width: min(760px, calc(100vw - 28px));
    background: color-mix(in srgb, var(--card-strong) 96%, black 4%);
    color: var(--ink);
    box-shadow: 0 30px 65px rgba(0, 0, 0, 0.42);
}

.forum-modal::backdrop {
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
}

.forum-modal-form {
    padding: 18px;
    display: grid;
    gap: 12px;
}

.forum-modal-form h2 {
    margin: 0;
}

.forum-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.thread-empty {
    color: var(--muted);
}

@media (max-width: 720px) {
    .forum-project-share-visuals.has-private {
        grid-template-columns: minmax(0, 1fr);
    }
}

.account-panel {
    display: grid;
    gap: var(--card-gap);
}

.account-intro h1 {
    margin-bottom: 12px;
}

.account-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.account-card {
    border-radius: 24px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
    padding: 18px;
    display: grid;
    gap: 12px;
}

.account-card h2 {
    margin: 0;
}

.admin-panel {
    display: grid;
    gap: var(--card-gap);
}

.admin-intro h1 {
    margin-bottom: 12px;
}

.admin-card {
    border-radius: 24px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
    padding: 18px;
    display: grid;
    gap: 12px;
}

.admin-card h2 {
    margin: 0;
}

.admin-image-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.admin-image-form {
    display: grid;
    gap: 12px;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: var(--card-muted);
}

.admin-image-form label,
.admin-search-label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.admin-image-form input[type="text"],
.admin-image-form input[type="search"],
.admin-search-label input,
.admin-image-form textarea,
.admin-image-form input[type="file"] {
    width: 100%;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--card-muted);
    color: var(--ink);
    font: inherit;
}

.admin-image-form input[type="text"],
.admin-image-form input[type="search"],
.admin-search-label input,
.admin-image-form input[type="file"] {
    min-height: 48px;
    padding: 0 14px;
}

.admin-image-form input[type="file"] {
    padding: 10px 14px;
}

.admin-image-form input[type="file"]::file-selector-button {
    border: 0;
    border-radius: 12px;
    min-height: 34px;
    padding: 0 12px;
    margin-right: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    font-weight: 600;
    cursor: pointer;
}

.admin-image-form input[type="file"]::file-selector-button:hover {
    background: linear-gradient(135deg, #ef7b55, #1fbaa4);
}

.admin-image-form textarea {
    padding: 12px 14px;
    resize: vertical;
}

.admin-user-name {
    font-weight: 600;
}

.admin-user-tag {
    color: var(--muted);
}

.admin-user-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.login-panel {
    display: grid;
    gap: var(--card-gap);
}

.login-intro h1 {
    margin-bottom: 12px;
}

.auth-tabs {
    display: inline-grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
    background: var(--card-muted);
    border: 1px solid var(--line);
    border-radius: 18px;
}

.auth-tab {
    border: 0;
    border-radius: 14px;
    min-height: 44px;
    padding: 0 18px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    font-weight: 600;
}

.auth-tab.is-active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
}

.auth-form {
    display: grid;
    gap: 14px;
}

.auth-form label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.auth-form input {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--card-muted);
    color: var(--ink);
    font: inherit;
}

.auth-form textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--card-muted);
    color: var(--ink);
    font: inherit;
    resize: vertical;
}

.auth-feedback {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
}

.auth-feedback.is-error {
    background: rgba(201, 72, 72, 0.12);
    border-color: rgba(201, 72, 72, 0.24);
    color: #d75a5a;
}

.auth-feedback.is-success {
    background: rgba(54, 168, 120, 0.12);
    border-color: rgba(54, 168, 120, 0.24);
    color: #2aa26c;
}

.home-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.02fr) minmax(420px, 0.98fr);
    gap: 34px;
    overflow: hidden;
    position: relative;
}

.hero-kicker {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent-soft), var(--accent-2-soft));
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.82rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.home-hero h1 {
    margin: 22px 0 18px;
    font-size: clamp(2.4rem, 5vw, 4.6rem);
    line-height: 1.03;
    max-width: 10ch;
}

.home-hero-copy .pixelate-copy {
    max-width: 58ch;
    font-size: 1.05rem;
    line-height: 1.55;
    margin-bottom: 0;
}

.home-page {
    gap: 24px;
}

.home-hero,
.community-stats-card,
.showcase-card {
    scroll-margin-top: 92px;
}

.home-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 30px 0 32px;
}

.home-hero-actions .dialog-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
}

.hero-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 8px;
}

.hero-metrics article,
.stitch-feature-card,
.workflow-card {
    border-radius: 24px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
}

.hero-metrics article {
    padding: 16px;
}

.hero-metrics strong,
.workflow-step {
    display: block;
    margin-bottom: 6px;
}

.hero-metrics span,
.workflow-card p,
.stitch-feature-card span {
    color: var(--muted);
}

.home-hero-art {
    position: relative;
    min-height: 620px;
    padding: 8px 6px 40px 18px;
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: auto auto;
    gap: 18px;
    align-content: start;
}

.hero-image-card {
    position: relative;
    z-index: 1;
    margin: 0;
    grid-column: 1 / -1;
    grid-row: 1;
    border-radius: 32px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
    box-shadow: var(--shadow);
}

.hero-image-card::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 45%;
    background: linear-gradient(180deg, transparent, rgba(8, 10, 15, 0.82));
    pointer-events: none;
}

.hero-image-card img {
    display: block;
    width: 100%;
    height: clamp(280px, 34vw, 420px);
    object-fit: cover;
    object-position: center;
}

.hero-image-credit {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 18px;
    z-index: 1;
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    border-radius: 18px;
    backdrop-filter: blur(16px);
    background: rgba(16, 20, 28, 0.42);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: rgba(255, 248, 243, 0.92);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease, background 180ms ease;
}

.hero-image-credit-label {
    font-family: "Space Grotesk", sans-serif;
    font-size: 0.74rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 248, 243, 0.72);
}

.hero-image-card:hover .hero-image-credit,
.hero-image-card:focus-within .hero-image-credit {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.hero-image-credit a {
    color: color-mix(in srgb, var(--accent-2) 72%, white 28%);
    text-decoration: none;
    font-weight: 700;
}

.hero-image-credit a:hover,
.hero-image-credit a:focus-visible {
    color: color-mix(in srgb, var(--accent) 58%, var(--accent-2) 42%);
    text-decoration: underline;
}

.stitch-orb {
    position: absolute;
    border-radius: 50%;
}

.stitch-orb-large {
    inset: 56% -6px auto auto;
    width: 170px;
    height: 170px;
    background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.34), transparent 30%),
        linear-gradient(135deg, rgba(255, 126, 95, 0.85), rgba(49, 199, 176, 0.86));
    opacity: 0.72;
}

.stitch-orb-small {
    inset: 18px auto auto -18px;
    width: 110px;
    height: 110px;
    background: linear-gradient(135deg, rgba(255, 196, 110, 0.84), rgba(255, 126, 95, 0.52));
    opacity: 0.58;
}

.stitch-card-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: 1.08fr 0.92fr;
    gap: 18px;
    margin-top: 2px;
    padding: 0 12px 0 4px;
}

.stitch-feature-card {
    padding: 18px;
    min-height: 154px;
    display: grid;
    align-content: start;
    gap: 10px;
    box-shadow: var(--shadow);
}

.stitch-feature-card:first-child {
    min-height: 148px;
}

.stitch-feature-card:nth-child(3) {
    min-height: 182px;
}

.stitch-feature-card:nth-child(2n) {
    transform: translateY(28px);
}

.stitch-feature-card:nth-child(3n) {
    transform: translateY(-10px);
}

.stitch-feature-card i {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.home-showcase {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.showcase-card {
    padding: 24px;
    display: grid;
    gap: 18px;
    align-content: start;
}

.showcase-figure-icon {
    display: grid;
    place-items: center;
    min-height: 220px;
}

.showcase-icon-pill {
    width: 86px;
    height: 86px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--line));
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 24%, transparent), color-mix(in srgb, var(--accent-2) 20%, transparent));
    color: color-mix(in srgb, var(--accent) 78%, var(--ink));
    font-size: 2rem;
}

.community-stats-card {
    display: grid;
    gap: 18px;
    padding: 24px;
    grid-column: 1 / -1;
}

.community-stats-head {
    display: grid;
    gap: 10px;
}

.community-stats-head h2,
.community-stats-head p {
    margin: 0;
}

.community-stats-head p {
    color: var(--muted);
    max-width: 68ch;
}

.community-kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.community-kpi-item {
    border-radius: 22px;
    border: 1px solid var(--line);
    background: var(--card-muted);
    padding: 16px;
    display: grid;
    align-content: start;
    gap: 8px;
}

.community-kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.community-kpi-item strong {
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    font-size: clamp(1.7rem, 2.8vw, 2.4rem);
    line-height: 1.1;
}

.community-kpi-note {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    color: var(--muted);
}

.community-stats-status {
    min-height: 24px;
    color: var(--muted);
}

.community-comparison-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.community-comparison-card {
    border-radius: 22px;
    border: 1px dashed var(--line);
    background: color-mix(in srgb, var(--card-muted) 90%, transparent 10%);
    padding: 16px;
    display: grid;
    gap: 8px;
}

.community-comparison-card strong,
.community-comparison-card p {
    margin: 0;
}

.community-comparison-card p {
    color: var(--muted);
}

.community-comparison-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-2);
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--accent-2-soft) 70%, transparent 30%);
}

.community-comparison-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 14px;
    border: 1px solid var(--line);
}

.showcase-card-wide {
    grid-column: 1 / -1;
    grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.2fr);
    align-items: center;
}

.showcase-copy {
    display: grid;
    gap: 12px;
    align-content: start;
}

.showcase-copy h2 {
    margin: 0;
}

.showcase-copy p {
    margin: 0;
    color: var(--muted);
}

.showcase-figure {
    margin: 0;
    border-radius: 22px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--card-muted) 88%, transparent 12%);
    box-shadow: var(--shadow);
}

.showcase-figure img {
    display: block;
    width: 100%;
    height: auto;
}

.showcase-card:not(.showcase-card-wide) .showcase-figure img {
    aspect-ratio: 16 / 10;
    object-fit: cover;
}

.workflow-step {
    color: var(--accent);
    font-weight: 700;
    letter-spacing: 0.12em;
}

.text-link {
    color: var(--accent-2);
    text-decoration: none;
    font-weight: 700;
}

.text-link:hover {
    text-decoration: underline;
}

.pixelate-panel,
.pixelate-preview-card,
.pixelate-legend-card,
.thread-color-intro,
.thread-color-photo-card,
.thread-color-result-card,
.thread-color-palette-card,
.pattern-sidebar,
.pattern-viewer {
    border-radius: 28px;
    gap: var(--card-gap);
}

.flow-section {
    position: relative;
    border: 1px solid color-mix(in srgb, var(--line) 80%, transparent 20%);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    background: color-mix(in srgb, var(--component-bg) 72%, transparent 28%);
}

.flow-section::before {
    content: attr(data-flow-step);
    position: absolute;
    top: -10px;
    left: 12px;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    border-radius: var(--radius-pill);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-family-ui);
    font-size: 0.78rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.flow-section-intro::before {
    content: none;
}

.pixelate-page,
.pattern-page {
    align-items: start;
}

.pixelate-panel .pixelate-actions,
.pattern-toolbar,
.pattern-progress-form {
    position: sticky;
    top: 10px;
    z-index: 2;
}

.pattern-list {
    max-height: calc(100vh - 320px);
    overflow: auto;
    padding-right: 4px;
}

.pattern-list .project-item {
    min-height: 68px;
    align-content: center;
}

.pixelate-legend-list,
.pattern-list {
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--accent-2) 55%, transparent) transparent;
}

.page > h1:first-child,
.pixelate-panel > div:first-child,
.pixelate-preview-card > .pixelate-preview-head:first-child,
.pixelate-legend-card > .pixelate-preview-head:first-child,
.thread-color-intro > div:first-child,
.thread-color-photo-card > .pixelate-preview-head:first-child,
.thread-color-result-card > .pixelate-preview-head:first-child,
.thread-color-palette-card > .thread-palette-header:first-child,
.pattern-sidebar > h1:first-child,
.pattern-viewer > #patternEmpty:first-child,
.pattern-viewer > .pattern-content:first-child,
.login-panel > .login-intro:first-child {
    margin-top: 0;
}

.page h1,
.page h2,
.page h3,
.pixelate-panel h1,
.pixelate-preview-card h2,
.pixelate-legend-card h2,
.thread-color-intro h1,
.thread-color-photo-card h2,
.thread-color-result-card h2,
.thread-color-palette-card h2,
.pattern-sidebar h1,
.pattern-viewer h2,
.login-panel h1 {
    margin-top: 0;
    margin-bottom: var(--card-header-gap);
}

.pixelate-dropzone,
.pixelate-empty,
.thread-sample-card,
.thread-best-match,
.thread-palette-card,
.pattern-canvas-wrap,
.pattern-sidepanel .pixelate-legend-list,
.pattern-minimap-wrap {
    background: var(--card-muted);
    border: 1px solid var(--line);
}

.pixelate-dropzone:hover,
.pixelate-dropzone.is-dragover,
.thread-palette-card:hover,
.showcase-card:hover,
.workflow-card:hover,
.stitch-feature-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.pixelate-dropzone {
    min-height: 180px;
    border-style: dashed;
}

.pixelate-preview figcaption,
.pixelate-copy,
.pixelate-meta,
.pattern-hover-info,
.thread-result-label {
    color: var(--muted);
}

.pattern-zoom-label,
.pixelate-summary {
    border: 1px solid var(--line);
    background: var(--card-muted);
}

.pattern-canvas-wrap canvas {
    border-radius: 18px;
}

.thread-palette-swatch,
.pixelate-legend-swatch,
.thread-match-swatch,
.thread-best-match-swatch {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.thread-stock-state,
.pixelate-legend-stock {
    border-radius: 999px;
}

@media (max-width: 1380px) {
    .site-header {
        grid-template-columns: minmax(0, 1fr) auto auto;
        grid-template-areas:
            "brand auth controls"
            "nav nav nav";
        justify-items: stretch;
        align-items: center;
    }

    .site-nav {
        justify-content: flex-start;
        margin-top: 4px;
        flex-wrap: wrap;
    }

    .site-nav-dropdown {
        left: 0;
        right: auto;
    }

    .theme-toggle {
        justify-content: center;
        justify-self: end;
        width: fit-content;
        max-width: max-content;
    }

    .locale-toggle {
        align-self: center;
    }

    .auth-nav {
        justify-content: flex-end;
        justify-self: end;
    }

    .home-hero,
    .home-showcase {
        grid-template-columns: 1fr;
    }

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

    .admin-image-grid {
        grid-template-columns: 1fr;
    }

    .community-kpi-grid,
    .community-comparison-grid {
        grid-template-columns: 1fr;
    }

    .home-hero-art {
        min-height: 440px;
        padding-left: 0;
        display: block;
    }

    .hero-metrics {
        grid-template-columns: 1fr;
    }

    .stitch-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding-right: 0;
    }

    .showcase-card-wide {
        grid-template-columns: 1fr;
    }

    .stitch-feature-card:nth-child(2n),
    .stitch-feature-card:nth-child(3n) {
        transform: translateY(0);
    }
}

@media (max-width: 760px) {
    body {
        padding: 16px 14px 28px;
    }

    .site-header,
    .page {
        border-radius: 24px;
        padding: var(--card-padding-mobile);
    }

    .global-utility-panel {
        top: 8px;
        right: 8px;
    }

    .global-utility-panel .header-controls {
        padding: 6px;
    }

    body.has-global-utility-panel {
        padding-top: 64px;
    }

    .site-nav {
        gap: 8px;
    }

    .site-nav-group,
    .site-nav-link {
        width: 100%;
    }

    .site-nav-trigger,
    .site-nav-link {
        width: 100%;
        justify-content: space-between;
        min-height: 46px;
        padding-left: 14px;
        padding-right: 14px;
    }

    .site-nav-dropdown {
        position: static;
        margin-top: 6px;
        min-width: 0;
        border-radius: var(--radius-md);
        padding: 6px;
        gap: 4px;
    }

    .site-nav-sub-link,
    .site-nav-sub-button {
        min-height: 40px;
        border-radius: var(--radius-sm);
        background: color-mix(in srgb, var(--component-bg) 86%, transparent 14%);
    }

    .site-nav-group.is-open .site-nav-trigger {
        box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-2) 40%, transparent 60%);
    }

    .site-header {
        gap: 10px;
    }

    .auth-nav {
        width: 100%;
        justify-content: flex-start;
        gap: 8px;
    }

    .forum-search-form {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
    }

    .forum-search-form input {
        min-width: 0;
    }

    .forum-compose-actions {
        justify-content: stretch;
    }

    .forum-compose-actions .dialog-button {
        width: 100%;
    }

    .pixelate-panel,
    .pixelate-preview-card,
    .pixelate-legend-card,
    .thread-color-intro,
    .thread-color-photo-card,
    .thread-color-result-card,
    .thread-color-palette-card,
    .pattern-sidebar,
    .pattern-viewer,
    .pattern-minimap-card,
    .login-panel,
    .account-panel,
    .admin-panel {
        padding: var(--card-padding-mobile);
    }

    .flow-section {
        padding: var(--space-3);
    }

    .flow-section::before {
        left: 10px;
    }

    .pattern-sidebar,
    .thread-color-result-card {
        position: static;
        top: auto;
    }

    .pixelate-panel .pixelate-actions,
    .pattern-toolbar,
    .pattern-progress-form {
        position: static;
    }

    .pattern-list {
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .home-hero h1 {
        max-width: none;
        font-size: clamp(2.1rem, 9vw, 3.4rem);
    }

    .stitch-card-grid,
    .hero-metrics,
    .home-showcase,
    .community-kpi-grid,
    .community-comparison-grid {
        grid-template-columns: 1fr;
    }

    .stitch-feature-card:nth-child(2n) {
        transform: none;
    }

    .admin-user-actions {
        flex-direction: column;
    }

    .admin-user-actions .site-nav-sub-button {
        width: 100%;
    }

    .home-hero-art {
        min-height: auto;
        padding-left: 0;
    }
}
