:root {
    --bg: #f3f5f1;
    --panel: #ffffff;
    --ink: #1f2933;
    --muted: #667085;
    --line: #c8d0c2;
    --accent: #2f6f5e;
    --accent-dark: #245849;
    --danger: #a83232;
    --shadow: 0 16px 40px rgba(31, 41, 51, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    overflow: hidden;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

.app-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px;
    height: 100svh;
    padding: 16px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 72px;
}

.topbar h1 {
    margin: 0;
    font-size: clamp(1.35rem, 2vw, 2rem);
    line-height: 1.05;
}

.topbar p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.create-form {
    display: grid;
    grid-template-columns: minmax(220px, 340px) 150px auto;
    gap: 8px;
    align-items: center;
}

.create-form input[type="text"],
.create-form select {
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    background: var(--panel);
}

.create-form button,
.secondary-button {
    height: 42px;
    border: 0;
    border-radius: 8px;
    padding: 0 16px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
}

.create-form button:hover,
.secondary-button:hover {
    background: var(--accent-dark);
}

.workspace {
    display: grid;
    grid-template-columns: 62px minmax(0, 1fr) 170px;
    gap: 12px;
    min-height: 0;
}

.legend,
.difficulty-legend {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.importance-legend {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0 26px;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.matrix-wrap {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    min-width: 0;
    min-height: 0;
}

.matrix {
    position: relative;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(47, 111, 94, 0.08), rgba(47, 111, 94, 0.02)),
        var(--panel);
    box-shadow: var(--shadow);
    touch-action: none;
}

.quadrant {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 50%;
    height: 50%;
    padding: 14px;
    color: rgba(31, 41, 51, 0.62);
    pointer-events: none;
}

.quadrant strong {
    font-size: clamp(1rem, 1.5vw, 1.45rem);
}

.quadrant span {
    font-size: 0.88rem;
}

.q-top-left {
    inset: 0 auto auto 0;
    background: rgba(247, 201, 72, 0.14);
}

.q-top-right {
    inset: 0 0 auto auto;
    align-items: flex-end;
    text-align: right;
    background: rgba(116, 185, 134, 0.16);
}

.q-bottom-left {
    inset: auto auto 0 0;
    justify-content: flex-end;
    background: rgba(220, 120, 90, 0.12);
}

.q-bottom-right {
    inset: auto 0 0 auto;
    align-items: flex-end;
    justify-content: flex-end;
    text-align: right;
    background: rgba(162, 191, 210, 0.14);
}

.center-axis {
    position: absolute;
    background: rgba(31, 41, 51, 0.2);
    pointer-events: none;
}

.center-axis-v {
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
}

.center-axis-h {
    right: 0;
    bottom: 50%;
    left: 0;
    height: 1px;
}

.labels-layer {
    position: absolute;
    inset: 0;
}

.label {
    position: absolute;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: min(280px, 30vw);
    min-height: 38px;
    border: 1px solid rgba(31, 41, 51, 0.22);
    border-radius: 8px;
    padding: 8px 10px 8px 12px;
    color: #1f2933;
    box-shadow: 0 8px 22px rgba(31, 41, 51, 0.18);
    cursor: grab;
    transform: translate(-50%, -50%);
    user-select: none;
}

.label[data-status="to_position"] {
    background: #eef0f3;
}

.label[data-status="not_started"] {
    background: #ffd7cc;
}

.label[data-status="in_progress"] {
    background: #ffe08a;
}

.label[data-status="done"] {
    background: #bdecc4;
}

.label:focus {
    outline: 3px solid rgba(47, 111, 94, 0.25);
}

.label.is-selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 111, 94, 0.18), 0 8px 22px rgba(31, 41, 51, 0.18);
}

.label.is-dragging {
    cursor: grabbing;
    z-index: 20;
}

.label-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.label-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.label-status {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    border: 1px solid rgba(31, 41, 51, 0.18);
    border-radius: 999px;
    padding: 2px 7px;
    background: rgba(255, 255, 255, 0.52);
    color: rgba(31, 41, 51, 0.78);
    cursor: pointer;
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
}

.drag-handle {
    font-weight: 800;
    letter-spacing: -0.14em;
    opacity: 0.62;
}

.delete-label {
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    color: var(--danger);
    font-weight: 800;
    line-height: 1;
    opacity: 0.72;
}

.delete-label:hover {
    background: rgba(168, 50, 50, 0.12);
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 1;
    color: var(--muted);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.empty-state.is-hidden {
    display: none;
}

.difficulty-legend {
    display: flex;
    justify-content: space-between;
    padding: 8px 4px 0;
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.status {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--panel);
    color: var(--muted);
    font-size: 0.9rem;
}

.status.is-saving {
    color: #9a6816;
}

.status.is-error {
    color: var(--danger);
}

.hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.35;
}

@media (max-width: 860px) {
    .app-shell {
        padding: 10px;
        gap: 10px;
    }

    .topbar {
        align-items: stretch;
        min-height: 0;
    }

    .topbar p,
    .side-panel .hint {
        display: none;
    }

    .create-form {
        grid-template-columns: minmax(140px, 1fr) 132px auto;
    }

    .workspace {
        grid-template-columns: 38px minmax(0, 1fr);
    }

    .side-panel {
        display: none;
    }
}
