:root {
    --ink: #151716;
    --text: #1f2522;
    --muted: #66726d;
    --panel: #ffffff;
    --panel-soft: #f4f8f7;
    --line: #dce5e2;
    --mint: #0f8c6d;
    --mint-dark: #08664e;
    --coral: #f06c5f;
    --yellow: #f0c84b;
    --violet: #7a63d8;
    --page: #edf3f1;
    --shadow: 0 16px 42px rgba(18, 23, 21, 0.12);
    --radius: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    color-scheme: light;
}

body {
    min-height: 100vh;
    background: var(--page);
    color: var(--text);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.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;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
}

.sidebar {
    background: var(--ink);
    color: #f8fbfa;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

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

.brand-logo {
    width: 58px;
    height: 58px;
    border-radius: var(--radius);
    background: #ffffff;
    object-fit: contain;
    padding: 5px;
}

.eyebrow {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.sidebar .eyebrow,
.sidebar-note p {
    color: #adbbb5;
}

h1 {
    font-size: 1.55rem;
    line-height: 1.1;
}

.upload-zone {
    min-height: 120px;
    border: 1px dashed rgba(255, 255, 255, 0.32);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.06);
    display: grid;
    place-items: center;
    gap: 4px;
    padding: 20px;
    text-align: center;
    transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.upload-zone:hover {
    border-color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.upload-zone span {
    font-weight: 900;
}

.upload-zone small {
    color: #adbbb5;
}

.upload-zone input {
    display: none;
}

.pack-panel,
.sidebar-note {
    display: grid;
    gap: 14px;
}

.section-heading {
    display: grid;
    gap: 2px;
}

.section-heading h2,
.section-heading h3 {
    line-height: 1.15;
}

.pack-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.pack-form input,
.field input,
.field select {
    min-width: 0;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--text);
    padding: 10px 11px;
}

.pack-form button,
.button-grid button,
.primary-button,
.ghost-button,
.export-button,
.mode-tab,
.segmented-control button {
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-weight: 900;
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.pack-form button,
.primary-button {
    background: var(--mint);
    color: #ffffff;
    padding: 10px 14px;
}

.pack-form button:hover,
.primary-button:hover {
    background: var(--mint-dark);
    transform: translateY(-1px);
}

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

.pack-item {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.06);
    color: #f8fbfa;
    padding: 12px;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.pack-item.active {
    background: #f8fbfa;
    color: var(--ink);
}

.pack-count {
    color: #adbbb5;
    font-size: 0.82rem;
    font-weight: 800;
}

.pack-item.active .pack-count {
    color: var(--muted);
}

.sidebar-note {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.13);
    padding-top: 18px;
}

.workspace {
    min-width: 0;
    padding: 26px;
    display: grid;
    gap: 22px;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.topbar h2 {
    max-width: 780px;
    font-size: clamp(1.7rem, 3vw, 3.1rem);
    line-height: 1.02;
}

.status-strip {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.status-strip span {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--muted);
    padding: 9px 11px;
    font-size: 0.86rem;
    font-weight: 800;
    box-shadow: 0 9px 22px rgba(18, 23, 21, 0.07);
}

.studio-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 22px;
    align-items: start;
}

.canvas-area,
.controls-panel,
.library-section {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.canvas-area {
    min-width: 0;
    overflow: hidden;
}

.canvas-toolbar {
    min-height: 76px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.ghost-button {
    background: var(--panel-soft);
    border-color: var(--line);
    color: var(--text);
    padding: 10px 13px;
}

.ghost-button:hover,
.button-grid button:hover,
.export-button:hover {
    border-color: var(--mint);
    transform: translateY(-1px);
}

.preview-stage {
    min-height: min(68vw, 620px);
    padding: 28px;
    display: grid;
    place-items: center;
    background:
        linear-gradient(45deg, #dfe7e4 25%, transparent 25%),
        linear-gradient(-45deg, #dfe7e4 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #dfe7e4 75%),
        linear-gradient(-45deg, transparent 75%, #dfe7e4 75%);
    background-color: #f8fbfa;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
    background-size: 24px 24px;
}

canvas {
    width: min(100%, 512px);
    max-height: 70vh;
    aspect-ratio: 1;
    border-radius: var(--radius);
    cursor: grab;
    filter: drop-shadow(0 20px 28px rgba(18, 23, 21, 0.18));
    touch-action: none;
    user-select: none;
}

canvas.is-brushing {
    cursor: crosshair;
}

canvas.is-dragging {
    cursor: grabbing;
}

.canvas-hint {
    width: min(100%, 512px);
    border: 1px solid rgba(15, 140, 109, 0.18);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.82);
    color: var(--muted);
    padding: 8px 10px;
    text-align: center;
    font-size: 0.84rem;
    font-weight: 800;
}

.platform-row {
    border-top: 1px solid var(--line);
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.export-button {
    background: var(--panel-soft);
    border-color: var(--line);
    color: var(--text);
    padding: 12px;
    display: grid;
    gap: 2px;
    text-align: left;
}

.export-button small {
    color: var(--muted);
    font-weight: 700;
}

.controls-panel {
    padding: 18px;
    display: grid;
    gap: 16px;
}

.control-section {
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 13px;
    padding-bottom: 16px;
}

.control-section:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.button-grid,
.split-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.button-grid button,
.mode-tab,
.segmented-control button {
    background: var(--panel-soft);
    border-color: var(--line);
    color: var(--text);
    padding: 11px 10px;
}

.mode-tabs,
.segmented-control {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.mode-tab.active,
.segmented-control button.active {
    background: #e3f4ee;
    border-color: var(--mint);
    color: var(--mint-dark);
}

.manual-tools {
    display: grid;
    gap: 12px;
}

.control-row {
    display: grid;
    gap: 8px;
}

.control-row span,
.field span,
.toggle-row span {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 800;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--mint);
}

input[type="color"] {
    min-height: 42px;
    padding: 4px;
}

.field {
    display: grid;
    gap: 7px;
}

.toggle-row {
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--mint);
}

.helper-copy {
    color: var(--muted);
    font-size: 0.86rem;
}

.library-section {
    padding: 20px;
    display: grid;
    gap: 16px;
}

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

.sticker-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-soft);
    overflow: hidden;
}

.sticker-card img {
    width: 100%;
    aspect-ratio: 1;
    display: block;
    object-fit: contain;
    padding: 12px;
    background:
        linear-gradient(45deg, #dde6e3 25%, transparent 25%),
        linear-gradient(-45deg, #dde6e3 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #dde6e3 75%),
        linear-gradient(-45deg, transparent 75%, #dde6e3 75%);
    background-color: #fbfdfc;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    background-size: 20px 20px;
}

.sticker-meta {
    border-top: 1px solid var(--line);
    padding: 10px;
    display: grid;
    gap: 8px;
}

.sticker-meta strong {
    font-size: 0.9rem;
}

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

.sticker-actions button {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--text);
    padding: 8px 9px;
    font-weight: 800;
}

.empty-state {
    min-height: 190px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    padding: 22px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 1120px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;
    }

    .pack-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

@media (max-width: 720px) {
    .sidebar,
    .workspace {
        padding: 18px;
    }

    .topbar {
        flex-direction: column;
    }

    .status-strip {
        justify-content: flex-start;
    }

    .pack-list,
    .platform-row,
    .button-grid,
    .split-fields {
        grid-template-columns: 1fr;
    }

    .preview-stage {
        min-height: auto;
        padding: 18px;
    }

    .canvas-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }
}
