:root {
    --panel: #ffffff;
    --canvas-bg: #eef2f8;
    --line: #e5e7eb;
    --text: #111827;
    --muted: #6b7280;
    --blue: #4096ff;
    --blue-dark: #1677ff;
    --soft: #f3f4f6;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--canvas-bg);
    overflow: hidden;
}

button,
input,
select {
    font: inherit;
}

.marker-app {
    display: grid;
    grid-template-columns: 266px minmax(360px, 1fr) 108px;
    grid-template-rows: 58px 1fr;
    width: 100vw;
    height: 100vh;
}

.topbar {
    grid-column: 1 / 4;
    display: grid;
    grid-template-columns: 266px 1fr auto;
    align-items: center;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    z-index: 5;
}

.topbar h1 {
    margin: 0;
    padding-left: 8px;
    font-size: 18px;
    font-weight: 500;
}

.toolstrip {
    display: flex;
    justify-content: center;
    gap: 20px;
    height: 100%;
}

.tool-btn {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    gap: 2px;
    border: 0;
    background: transparent;
    color: #333;
    cursor: pointer;
    font-size: 12px;
}

.tool-btn:hover,
.tool-btn.active {
    color: var(--blue-dark);
}

.tool-icon {
    font-size: 22px;
    line-height: 1;
}

.file-tool input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-right: 18px;
}

.ghost-link,
.primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    height: 32px;
    padding: 0 16px;
    border: 0;
    text-decoration: none;
    cursor: pointer;
}

.ghost-link {
    background: #f1f3f5;
    color: #344054;
}

.primary-btn {
    background: var(--blue);
    color: white;
}

.left-panel,
.right-panel {
    background: var(--panel);
}

.left-panel {
    grid-column: 1;
    grid-row: 2;
    overflow-y: auto;
    border-right: 1px solid var(--line);
}

.panel-section {
    padding: 12px 8px 14px;
    border-bottom: 1px solid var(--line);
}

.panel-section h2 {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
}

.segmented {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.seg {
    min-width: 58px;
    height: 32px;
    border: 1px solid #edf0f3;
    background: #f8fafc;
    cursor: pointer;
}

.seg.active {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 58px;
    gap: 10px;
    margin-bottom: 14px;
}

.two-col label,
.full-field,
.size-grid label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
}

.stepper {
    display: grid;
    grid-template-columns: 28px 1fr 28px;
    height: 28px;
    background: #f0f2f5;
}

.stepper button {
    border: 0;
    background: #e6e9ee;
    color: #667085;
    cursor: pointer;
    font-size: 20px;
}

.stepper input {
    width: 100%;
    border: 0;
    background: #f7f8fa;
    text-align: center;
}

.color-input,
.full-field input[type="color"] {
    width: 46px;
    height: 28px;
    padding: 0;
    border: 0;
    background: transparent;
}

.full-field {
    margin-top: 4px;
}

.full-field input[type="color"] {
    width: 100%;
    border: 1px solid var(--line);
}

.layer-actions {
    display: flex;
    gap: 15px;
    padding: 4px 8px 12px;
}

.layer-actions button {
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
}

.layer-actions button:hover {
    color: var(--blue-dark);
}

.layer-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.layer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 32px;
    padding: 6px 8px;
    border: 1px solid var(--line);
    background: #fafafa;
    cursor: pointer;
    font-size: 13px;
}

.layer-item.active {
    border-color: var(--blue);
    color: var(--blue-dark);
}

.layer-item.locked {
    opacity: .55;
}

.tab-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-bottom: 10px;
    background: #eef0f3;
    padding: 2px;
}

.tab-pair button {
    height: 28px;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.tab-pair .active {
    background: white;
    color: var(--blue-dark);
}

#measurePanel input,
#measurePanel select,
.size-grid input {
    width: 100%;
    height: 30px;
    margin-bottom: 8px;
    padding: 0 10px;
    border: 1px solid #edf0f3;
    background: #f4f5f7;
}

.switch-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 34px;
    font-size: 13px;
}

.switch-row input {
    width: 28px;
    accent-color: var(--blue);
}

.size-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.wide-btn {
    width: 100%;
    height: 34px;
    margin-top: 8px;
    border: 0;
    background: var(--blue);
    color: #fff;
    cursor: pointer;
}

.wide-btn.secondary {
    background: #e9ecef;
    color: #1f2937;
}

.workspace {
    grid-column: 2;
    grid-row: 2;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 42px;
}

.canvas-shell {
    position: relative;
    background: white;
    box-shadow: 0 1px 0 rgba(15, 23, 42, .02);
}

#editorCanvas {
    display: block;
    max-width: min(78vw, 1000px);
    max-height: calc(100vh - 130px);
    background: #fff;
}

.empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #6b7280;
    pointer-events: none;
}

.empty-state[hidden] {
    display: none;
}

.empty-state strong {
    color: #202938;
    font-size: 20px;
}

.right-panel {
    grid-column: 3;
    grid-row: 2;
    border-left: 1px solid var(--line);
    padding: 10px 8px;
}

.thumb-card {
    width: 84px;
    min-height: 98px;
    border: 2px solid var(--blue);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

#thumbCanvas {
    width: 74px;
    height: 74px;
    object-fit: contain;
}

.ref-card {
    margin-top: 14px;
    font-size: 12px;
    color: var(--muted);
}

.ref-card img {
    display: block;
    width: 84px;
    max-height: 120px;
    margin-top: 6px;
    object-fit: contain;
    border: 1px solid var(--line);
}

@media (max-width: 980px) {
    .marker-app {
        grid-template-columns: 220px 1fr;
    }

    .right-panel {
        display: none;
    }

    .topbar {
        grid-column: 1 / 3;
        grid-template-columns: 220px 1fr auto;
    }

    .toolstrip {
        gap: 8px;
    }
}
