:root {
    --whiteboard-bg: #f5f5f7;
    --surface: rgba(255, 255, 255, 0.86);
    --surface-strong: #ffffff;
    --surface-muted: #f9fafb;
    --panel-border: rgba(29, 29, 31, 0.10);
    --panel-border-strong: rgba(29, 29, 31, 0.16);
    --ink: #1d1d1f;
    --muted: #6e7480;
    --muted-soft: #9aa3af;
    --brand: #0a84ff;
    --brand-strong: #0066d6;
    --button-bg: #f5f7fb;
    --button-hover: #edf4ff;
    --shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.05), 0 18px 50px rgba(15, 23, 42, 0.08);
    --shadow-panel: 0 1px 1px rgba(15, 23, 42, 0.04), 0 10px 28px rgba(15, 23, 42, 0.07);
}

html,
body {
    min-height: 100%;
    overscroll-behavior: none;
}

body {
    background:
        radial-gradient(circle at 18% 0%, rgba(10, 132, 255, 0.08), transparent 26%),
        linear-gradient(180deg, #fbfbfd 0%, var(--whiteboard-bg) 46%, #eef1f5 100%);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
    letter-spacing: 0;
}

button,
input,
select {
    font: inherit;
}

body > header {
    border-bottom: 1px solid rgba(29, 29, 31, 0.08);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: none;
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
}

body > header .container {
    max-width: 1440px;
    padding: 14px 24px;
}

body > header .logo img {
    width: 44px;
    height: 44px;
    border-radius: 8px;
}

body > header .logo-text h1 {
    color: #1671d6;
    font-size: 22px;
    letter-spacing: 0;
}

body > header .logo-text p {
    color: #6e7480;
    font-size: 12px;
}

body > header nav ul li {
    margin-left: 30px;
}

body > header nav ul li a {
    color: #2f3338;
    font-size: 15px;
    font-weight: 650;
}

.whiteboard-app {
    min-height: calc(100vh - 73px);
    padding: 22px clamp(18px, 3vw, 34px);
}

.whiteboard-shell {
    display: grid;
    grid-template-columns: 92px minmax(620px, 1fr) 304px;
    gap: 18px;
    max-width: 1840px;
    min-height: calc(100vh - 118px);
    margin: 0 auto;
}

.tool-panel,
.property-panel,
.canvas-stage {
    border: 1px solid var(--panel-border);
    background: var(--surface);
    box-shadow: var(--shadow-panel);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.tool-panel,
.property-panel {
    border-radius: 8px;
    overflow: auto;
}

.tool-panel {
    padding: 12px;
}

.property-panel {
    padding: 18px;
}

.property-section {
    display: none;
}

.property-section.visible {
    display: block;
}

.panel-section + .panel-section {
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid rgba(29, 29, 31, 0.08);
}

.panel-title {
    margin-bottom: 12px;
    color: #1d1d1f;
    font-size: 13px;
    font-weight: 750;
    line-height: 1.2;
}

.tool-panel .panel-title {
    color: #7b8493;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.tool-btn,
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(61, 79, 105, 0.13);
    background: rgba(248, 250, 252, 0.82);
    color: #344155;
    cursor: pointer;
    transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.tool-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 15px;
}

.tool-btn:hover,
.icon-btn:hover {
    border-color: rgba(10, 132, 255, 0.34);
    color: var(--brand);
    background: var(--button-hover);
}

.tool-btn:active,
.icon-btn:active,
.primary-btn:active {
    transform: scale(0.98);
}

.tool-btn.active {
    background: #1f7aff;
    border-color: #1f7aff;
    color: #ffffff;
    box-shadow: 0 7px 18px rgba(10, 132, 255, 0.24);
}

.tool-icon {
    display: block;
    position: relative;
}

.line-icon {
    width: 22px;
    height: 22px;
}

.line-icon::before {
    content: "";
    position: absolute;
    left: 3px;
    top: 16px;
    width: 23px;
    height: 2px;
    background: currentColor;
    transform: rotate(-52deg);
    transform-origin: left center;
}

.dashed-line-icon {
    width: 25px;
    height: 22px;
}

.dashed-line-icon::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 16px;
    width: 24px;
    border-top: 2px dashed currentColor;
    transform: rotate(-52deg);
    transform-origin: left center;
}

.ellipse-icon {
    width: 22px;
    height: 13px;
    border: 2px solid currentColor;
    border-radius: 50%;
}

.rotate-triangle {
    transform: rotate(-90deg);
}

.canvas-stage {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-width: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
    box-shadow: var(--shadow-soft);
}

.stage-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 72px;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(29, 29, 31, 0.09);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(250, 251, 253, 0.92));
}

.board-title {
    min-width: 0;
}

.board-title h1 {
    margin: 0;
    color: #15171a;
    font-size: 25px;
    font-weight: 780;
    letter-spacing: 0;
    line-height: 1.08;
}

.board-title span {
    display: block;
    margin-top: 5px;
    color: #6f7b8f;
    font-size: 13px;
    font-weight: 550;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.action-row {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-shrink: 0;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 14px;
}

.icon-btn:disabled {
    opacity: 0.38;
    cursor: default;
    transform: none;
}

.primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 15px;
    border: 0;
    border-radius: 8px;
    color: #ffffff;
    background: linear-gradient(180deg, #2388ff 0%, #0a6ee8 100%);
    cursor: pointer;
    font-weight: 760;
    box-shadow: 0 8px 18px rgba(10, 132, 255, 0.24);
    transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.primary-btn:hover {
    background: linear-gradient(180deg, #147cff 0%, var(--brand-strong) 100%);
    box-shadow: 0 10px 24px rgba(10, 132, 255, 0.30);
}

.canvas-wrap {
    position: relative;
    min-height: 560px;
    background: #f2f4f8;
    overflow: hidden;
    touch-action: none;
}

#whiteboardCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.eraser-cursor {
    position: absolute;
    left: 0;
    top: 0;
    display: none;
    width: 28px;
    height: 28px;
    border: 2px solid rgba(17, 24, 39, 0.94);
    border-radius: 50%;
    background: rgba(10, 132, 255, 0.10);
    pointer-events: none;
    transform: translate3d(0, 0, 0) translate(-50%, -50%);
    will-change: transform;
    contain: paint;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.96), 0 0 0 4px rgba(10, 132, 255, 0.26);
    z-index: 6;
}

.eraser-cursor::before,
.eraser-cursor::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    background: rgba(17, 24, 39, 0.55);
    transform: translate(-50%, -50%);
}

.eraser-cursor::before {
    width: 44%;
    height: 1px;
}

.eraser-cursor::after {
    width: 1px;
    height: 44%;
}

.text-input {
    position: absolute;
    display: none;
    min-width: 130px;
    max-width: min(420px, 78vw);
    height: 38px;
    padding: 7px 10px;
    border: 1px solid var(--brand);
    border-radius: 8px;
    outline: none;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
    color: var(--ink);
    z-index: 5;
}

.field-label {
    display: block;
    margin: 13px 0 7px;
    color: #6f7b8f;
    font-size: 12px;
    font-weight: 720;
}

.slider-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.slider-label span {
    color: #728095;
    font-variant-numeric: tabular-nums;
}

.color-input {
    width: 100%;
    height: 38px;
    padding: 4px;
    border: 1px solid rgba(45, 65, 91, 0.16);
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
}

.color-swatches,
.background-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 9px;
    margin-top: 12px;
}

.color-swatches button,
.background-presets button {
    height: 31px;
    border: 1px solid rgba(30, 41, 59, 0.14);
    border-radius: 8px;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.36);
    transition: transform 0.16s ease, outline-color 0.16s ease, box-shadow 0.16s ease;
}

.color-swatches button:hover,
.background-presets button:hover {
    transform: translateY(-1px);
}

.color-swatches button.active,
.background-presets button.active {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    box-shadow: inset 0 0 0 2px #ffffff, 0 6px 16px rgba(10, 132, 255, 0.18);
}

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

select {
    width: 100%;
    height: 42px;
    border: 1px solid rgba(45, 65, 91, 0.16);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    padding: 0 12px;
    font-weight: 650;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    color: #344155;
    font-size: 14px;
    font-weight: 620;
    cursor: pointer;
}

.check-row input {
    width: 17px;
    height: 17px;
    accent-color: var(--brand);
}

@media (max-width: 1180px) {
    .whiteboard-shell {
        grid-template-columns: 92px minmax(0, 1fr);
    }

    .property-panel {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 18px;
    }

    .property-panel .panel-section + .panel-section {
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
    }
}

@media (max-width: 760px) {
    body > header .container {
        padding: 12px 16px;
    }

    body > header .logo-text h1 {
        font-size: 18px;
    }

    body > header .logo-text p {
        display: none;
    }

    .whiteboard-app {
        padding: 10px;
    }

    .whiteboard-shell {
        display: flex;
        flex-direction: column;
        min-height: auto;
        gap: 12px;
    }

    .tool-panel {
        display: flex;
        gap: 14px;
        overflow-x: auto;
        padding: 12px;
        scroll-snap-type: x proximity;
    }

    .tool-panel .panel-section {
        min-width: 186px;
        scroll-snap-align: start;
    }

    .tool-panel .panel-section + .panel-section {
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
    }

    .tool-grid {
        grid-template-columns: repeat(4, 36px);
        gap: 8px;
    }

    .tool-btn {
        width: 36px;
        height: 36px;
    }

    .stage-topbar {
        align-items: flex-start;
        flex-direction: column;
        min-height: auto;
        padding: 14px;
    }

    .board-title h1 {
        font-size: 24px;
    }

    .action-row {
        width: 100%;
        justify-content: space-between;
    }

    .canvas-wrap {
        height: 56vh;
        min-height: 390px;
    }

    .property-panel {
        display: block;
        padding: 16px;
    }

    .property-panel .panel-section + .panel-section {
        margin-top: 22px;
        padding-top: 20px;
        border-top: 1px solid rgba(29, 29, 31, 0.08);
    }
}
