:root {
    color-scheme: light;
    font-family: Inter, "Segoe UI", sans-serif;
    color: #242821;
    background: #f2f0ea;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}

* {
    box-sizing: border-box;
}

html,
body,
#app {
    width: 100%;
    height: 100%;
    min-width: 320px;
    min-height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    background: #f2f0ea;
}

button {
    font: inherit;
}

.editor-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.editor-header {
    z-index: 1;
    display: flex;
    flex: 0 0 76px;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.5rem;
    border-bottom: 1px solid #deddd5;
    background: #fbfaf7;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.brand-mark {
    display: block;
    flex: 0 0 2.6rem;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 0.65rem;
    object-fit: cover;
}

.brand-block h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.brand-block h1:focus {
    outline: none;
}

.brand-block p {
    overflow: hidden;
    margin: 0.25rem 0 0;
    color: #6a6d64;
    font-size: 0.78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-summary {
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.83rem;
}

.document-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.document-actions button,
.file-action,
.language-picker {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    padding: 0.45rem 0.72rem;
    border: 1px solid #d2d4ca;
    border-radius: 0.55rem;
    color: #343a30;
    background: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}

.language-picker select {
    max-width: 7rem;
    border: 0;
    color: inherit;
    background: transparent;
    font: inherit;
    cursor: pointer;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

.document-actions button:hover,
.file-action:hover {
    border-color: #82916e;
    background: #f4f6f0;
}

.document-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.file-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.save-status {
    color: #6a6d64;
    font-size: 0.7rem;
}

.operation-error {
    z-index: 2;
    margin: 0;
    padding: 0.45rem 1rem;
    color: #842c27;
    background: #fff0ed;
    font-size: 0.82rem;
}

.document-summary strong {
    font-weight: 650;
}

.app-footer {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    min-height: 2.5rem;
    padding: 0 1.5rem;
    border-top: 1px solid #deddd5;
    background: #fbfaf7;
    font-size: 0.72rem;
}

.app-footer a {
    color: #53604c;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.15em;
}

.local-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #62675e;
    font-size: 0.73rem;
}

.local-status > span {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: #82916e;
}

.editor-workspace {
    display: grid;
    flex: 1 1 auto;
    grid-template-columns: 76px minmax(0, 1fr) 230px;
    gap: 0.8rem;
    min-height: 0;
    padding: 0.8rem;
}

.tool-panel {
    display: flex;
    align-items: center;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.45rem;
    border: 1px solid #deddd5;
    border-radius: 1rem;
    background: #fbfaf7;
    overflow-y: auto;
}

.tool-button {
    display: flex;
    align-items: center;
    flex-direction: column;
    justify-content: center;
    gap: 0.3rem;
    width: 100%;
    min-height: 4.1rem;
    padding: 0.5rem 0.2rem;
    border: 1px solid transparent;
    border-radius: 0.7rem;
    color: #51564d;
    background: transparent;
    cursor: pointer;
    font-size: 0.67rem;
}

.tool-button > span:first-child {
    font-size: 1.35rem;
    line-height: 1;
}

.tool-button:hover {
    background: #f0efe8;
}

.tool-button[aria-pressed="true"] {
    border-color: #d9e0d2;
    color: #33432d;
    background: #e9ede4;
}

.tool-button:focus-visible,
.canvas-zoom-controls button:focus-visible,
.sketch-svg:focus-visible {
    outline: 2px solid #657a59;
    outline-offset: 2px;
}

.canvas-frame {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border: 1px solid #d7d7cf;
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 1px 3px rgba(35, 39, 31, 0.04);
}

.canvas-frame.is-panning .sketch-svg {
    cursor: grabbing;
}

.sketch-svg {
    display: block;
    width: 100%;
    height: 100%;
    background: #fff;
    cursor: default;
    touch-action: none;
    user-select: none;
}

.canvas-frame[data-tool="freehand"] .sketch-svg {
    cursor: crosshair;
}

.canvas-frame[data-tool="line"] .sketch-svg,
.canvas-frame[data-tool="rectangle"] .sketch-svg,
.canvas-frame[data-tool="ellipse"] .sketch-svg,
.canvas-frame[data-tool="circle"] .sketch-svg,
.canvas-frame[data-tool="polygon"] .sketch-svg {
    cursor: crosshair;
}

.canvas-frame[data-tool="text"] .sketch-svg,
.canvas-frame[data-tool="sticky-note"] .sketch-svg {
    cursor: crosshair;
}

.inline-text-editor {
    position: absolute;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    width: min(20rem, calc(100% - 1rem));
    padding: 0.4rem;
    border: 1px solid #b7c0ae;
    border-radius: 0.55rem;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 3px 12px rgba(35, 39, 31, 0.14);
}

.inline-text-editor textarea,
.appearance-group textarea {
    width: 100%;
    min-height: 4rem;
    padding: 0.45rem;
    border: 1px solid #d3d2ca;
    border-radius: 0.4rem;
    color: inherit;
    background: #fff;
    font: inherit;
    resize: vertical;
}

.inline-text-editor textarea {
    min-height: 5rem;
    border-color: transparent;
    background: transparent;
}

.inline-text-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
}

.inline-text-actions button {
    padding: 0.3rem 0.55rem;
    border: 1px solid #d3d2ca;
    border-radius: 0.4rem;
    color: #34382f;
    background: #f5f4ef;
    cursor: pointer;
    font-size: 0.72rem;
}

.inline-text-actions button:first-child {
    border-color: #657a59;
    color: #fff;
    background: #657a59;
}

.drawing-object,
.drawing-preview {
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

.sketch-svg text {
    pointer-events: none;
}

.drawing-preview {
    opacity: 0.8;
}

.selection-bounds {
    fill: rgba(100, 125, 83, 0.06);
    stroke: #6f875e;
    stroke-dasharray: 5 4;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

.image-resize-handle {
    fill: #fff;
    stroke: #53604c;
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
}

.image-resize-handle[data-resize-handle="top-left"],
.image-resize-handle[data-resize-handle="bottom-right"] {
    cursor: nwse-resize;
}

.image-resize-handle[data-resize-handle="top-right"],
.image-resize-handle[data-resize-handle="bottom-left"] {
    cursor: nesw-resize;
}

.canvas-zoom-controls {
    position: absolute;
    z-index: 2;
    top: 0.8rem;
    right: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem;
    border: 1px solid #deddd5;
    border-radius: 0.7rem;
    background: rgba(251, 250, 247, 0.96);
    box-shadow: 0 2px 8px rgba(35, 39, 31, 0.08);
}

.canvas-zoom-controls button {
    min-width: 2.1rem;
    height: 2rem;
    padding: 0 0.45rem;
    border: 0;
    border-radius: 0.45rem;
    color: #3f453a;
    background: transparent;
    cursor: pointer;
    font-size: 0.85rem;
}

.canvas-zoom-controls button:hover {
    background: #eeede7;
}

.canvas-zoom-controls output {
    min-width: 3.3rem;
    color: #565a51;
    font-size: 0.76rem;
    text-align: center;
}

.properties-panel {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-width: 0;
    padding: 0.9rem;
    overflow-y: auto;
    border: 1px solid #deddd5;
    border-radius: 1rem;
    background: #fbfaf7;
}

.properties-panel h2 {
    margin: 0;
    font-size: 0.95rem;
}

.appearance-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
    margin: 0;
    padding: 0.55rem;
    border: 1px solid #e1e0d8;
    border-radius: 0.55rem;
}

.appearance-group legend {
    padding: 0 0.25rem;
    color: #42483d;
    font-size: 0.75rem;
    font-weight: 650;
}

.properties-context {
    margin: -0.3rem 0 0.35rem;
    color: #6a6d64;
    font-size: 0.73rem;
}

.properties-panel label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    color: #4d5149;
    font-size: 0.74rem;
}

.properties-panel input[type="color"] {
    width: 100%;
    height: 2rem;
    padding: 0.15rem;
    border: 1px solid #d3d2ca;
    border-radius: 0.4rem;
    background: #fff;
}

.properties-panel input[type="range"] {
    width: 100%;
    accent-color: #657a59;
}

.properties-panel select {
    width: 100%;
    min-height: 2rem;
    padding: 0.2rem 0.4rem;
    border: 1px solid #d3d2ca;
    border-radius: 0.4rem;
    color: #34382f;
    background: #fff;
    font: inherit;
    font-size: 0.76rem;
}

.properties-panel .check-field {
    justify-content: flex-start;
    margin-top: 0.2rem;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    z-index: 1000;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 0.75rem 1rem;
    color: #fff;
    background: #8e302b;
}

#blazor-error-ui a {
    color: inherit;
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    cursor: pointer;
}

.loading-progress {
    position: absolute;
    display: block;
    width: 5rem;
    height: 5rem;
    inset: 28vh 0 auto;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: #d9d7ce;
    stroke-width: 0.55rem;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

.loading-progress circle:last-child {
    stroke: #728565;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    inset: calc(28vh + 6rem) 0 auto;
    text-align: center;
}

.loading-progress-text:empty::after {
    content: var(--blazor-load-percentage-text, "Laden");
}

@media (max-width: 1080px) {
    .editor-header {
        flex: 0 0 auto;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "brand summary"
            "actions actions";
        gap: 0.45rem 0.8rem;
        padding: 0.55rem 1rem;
    }

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

    .document-actions {
        grid-area: actions;
        flex-wrap: wrap;
    }

    .document-summary {
        grid-area: summary;
    }
}

@media (max-width: 600px) {
    .app-footer {
        min-height: 2.75rem;
        padding: 0 0.65rem;
    }

    .editor-header {
        min-height: 66px;
        padding: 0.45rem 0.65rem;
    }

    .brand-block {
        gap: 0.55rem;
    }

    .brand-mark {
        flex-basis: 2.2rem;
        width: 2.2rem;
        height: 2.2rem;
    }

    .brand-block h1 {
        font-size: 0.92rem;
    }

    .brand-block p {
        display: none;
    }

    .document-actions {
        gap: 0.25rem;
        justify-content: flex-start;
    }

    .document-actions button,
    .file-action,
    .language-picker {
        min-height: 2rem;
        padding: 0.35rem 0.45rem;
        font-size: 0.67rem;
    }

    .language-picker select {
        max-width: 5rem;
        font-size: 0.67rem;
    }

    .document-summary {
        font-size: 0.74rem;
    }

    .document-summary strong,
    .save-status {
        display: none;
    }

    .editor-workspace {
        grid-template-columns: 56px minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) minmax(8rem, 29vh);
        gap: 0.45rem;
        padding: 0.45rem;
    }

    .tool-panel {
        padding: 0.3rem;
        grid-column: 1;
        grid-row: 1;
    }

    .tool-button {
        min-height: 3.6rem;
        font-size: 0.57rem;
    }

    .canvas-frame {
        grid-column: 2;
        grid-row: 1;
    }

    .properties-panel {
        grid-column: 1 / 3;
        grid-row: 2;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-content: start;
        overflow: auto;
        padding: 0.65rem;
    }

    .properties-panel h2,
    .properties-context {
        grid-column: 1 / -1;
    }

    .properties-panel input[type="color"],
    .properties-panel input[type="range"],
    .properties-panel select {
        min-width: 0;
    }

    .canvas-zoom-controls {
        top: 0.5rem;
        right: 0.5rem;
    }
}

@media (max-width: 380px) {
    .editor-header {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "brand"
            "summary"
            "actions";
    }

    .document-summary {
        align-items: flex-start;
    }
}
