:root {
    --ink: #24211d;
    --muted-ink: #6d6558;
    --paper: #f1ead8;
    --paper-deep: #ddd1b8;
    --desk: #33423d;
    --desk-dark: #1d2927;
    --brass: #a98142;
    --oxide: #52716d;
    --red: #a54b43;
    --shadow: rgba(26, 22, 16, 0.35);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
}

body {
    margin: 0;
    overflow: hidden;
    color: var(--ink);
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", "Courier New", monospace;
    background:
        linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px),
        linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
        linear-gradient(135deg, #435752, #222f2d 58%, #17211f);
    background-size: 36px 36px, 36px 36px, auto;
}

button,
textarea {
    font: inherit;
}

button {
    color: inherit;
}

.desktop-shell {
    position: relative;
    width: 100vw;
    height: 100vh;
    min-width: 320px;
    padding: 22px 22px 74px;
    isolation: isolate;
}

.desk-panel {
    position: relative;
    z-index: 2;
    border: 2px solid #201c18;
    background: var(--paper);
    box-shadow: 5px 6px 0 rgba(0, 0, 0, 0.28);
}

.memo-panel {
    width: min(480px, calc(100vw - 44px));
    min-height: 520px;
}

.panel-titlebar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    min-height: 34px;
    padding: 6px 10px;
    border-bottom: 2px solid #201c18;
    color: #f4ead1;
    background: #24211d;
    font-size: 13px;
    letter-spacing: 0;
    text-transform: uppercase;
}

.title-light {
    width: 10px;
    height: 10px;
    border: 1px solid #ead7a5;
    background: var(--red);
    box-shadow: inset 1px 1px 0 rgba(255,255,255,0.35);
}

.panel-code {
    color: #c8b588;
}

.memo-paper {
    position: relative;
    margin: 16px;
    min-height: 370px;
    border: 2px solid #7d715f;
    background:
        linear-gradient(rgba(165,75,67,0.16) 1px, transparent 1px),
        linear-gradient(90deg, transparent 38px, rgba(165,75,67,0.42) 39px, transparent 40px),
        #f8f0dc;
    background-size: 100% 28px, auto, auto;
    box-shadow: inset 0 0 0 4px rgba(255,255,255,0.28);
}

.paper-rings {
    position: absolute;
    left: 10px;
    top: 18px;
    bottom: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
}

.paper-rings span {
    width: 12px;
    height: 12px;
    border: 2px solid #8b7b62;
    border-radius: 50%;
    background: #d7ccb2;
}

#memoInput {
    width: 100%;
    min-height: 366px;
    padding: 18px 18px 18px 58px;
    border: 0;
    outline: 0;
    resize: none;
    color: var(--ink);
    background: transparent;
    line-height: 28px;
    font-size: 15px;
}

#memoInput::placeholder {
    color: #8a806e;
}

.tag-board {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 16px;
}

.tag-chip,
.task-button,
.window-control {
    border: 2px solid #201c18;
    background: #d9c8a5;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.25);
    cursor: pointer;
}

.tag-chip {
    min-height: 34px;
    padding: 6px 10px;
    text-align: left;
}

.tag-chip:hover,
.tag-chip.active {
    background: #f4dfa9;
}

.inspector-panel {
    position: absolute;
    top: 22px;
    right: 22px;
    width: 270px;
}

.status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 2px solid #201c18;
}

.status-grid div {
    min-height: 86px;
    padding: 14px;
    border-right: 2px solid #201c18;
}

.status-grid div:last-child {
    border-right: 0;
}

.status-grid strong {
    display: block;
    overflow: hidden;
    color: var(--red);
    font-size: 24px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-grid span,
.extension-note span {
    display: block;
    color: var(--muted-ink);
    font-size: 12px;
    text-transform: uppercase;
}

.extension-note {
    padding: 14px;
    line-height: 1.55;
}

.extension-note p {
    margin: 8px 0 0;
    font-size: 13px;
}

.window-layer {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
}

.dialog-window {
    position: absolute;
    display: flex;
    flex-direction: column;
    width: 330px;
    min-width: 240px;
    min-height: 160px;
    border: 2px solid #15120f;
    background: var(--paper);
    box-shadow: 7px 8px 0 var(--shadow);
    pointer-events: auto;
}

.dialog-window.maximized {
    left: 16px !important;
    top: 16px !important;
    width: calc(100vw - 32px) !important;
    height: calc(100vh - 94px) !important;
}

.dialog-window.minimized {
    display: none;
}

.window-titlebar {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 5px 6px 5px 10px;
    border-bottom: 2px solid #15120f;
    color: #f5ecd8;
    background: var(--oxide);
    cursor: grab;
    user-select: none;
}

.window-titlebar:active {
    cursor: grabbing;
}

.window-title {
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.window-controls {
    display: flex;
    gap: 4px;
}

.window-control {
    display: grid;
    width: 23px;
    height: 22px;
    place-items: center;
    padding: 0;
    background: #efe0bd;
    font-size: 13px;
    line-height: 1;
}

.window-control.close {
    background: #d98376;
}

.window-body {
    flex: 1;
    min-height: 0;
    padding: 12px;
    overflow: auto;
    background:
        repeating-linear-gradient(0deg, rgba(82,113,109,0.08), rgba(82,113,109,0.08) 1px, transparent 1px, transparent 24px),
        var(--paper);
}

.window-footer {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 10px;
    border-top: 2px solid #15120f;
    color: var(--muted-ink);
    background: var(--paper-deep);
    font-size: 12px;
}

.resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 18px;
    height: 18px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, rgba(36,33,29,0.35) 50%);
}

.empty-module {
    display: grid;
    min-height: 118px;
    place-items: center;
    border: 2px dashed #8a7d66;
    color: var(--muted-ink);
    text-align: center;
}

.module-stamp {
    border: 2px solid var(--red);
    color: var(--red);
    padding: 4px 8px;
    text-transform: uppercase;
    transform: rotate(-4deg);
}

.empty-module p {
    margin: 0 12px 12px;
}

.taskbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    gap: 8px;
    min-height: 54px;
    padding: 9px 12px;
    border-top: 2px solid #111;
    background: #1f2725;
    overflow-x: auto;
}

.task-button {
    flex: 0 0 auto;
    max-width: 190px;
    min-width: 98px;
    min-height: 34px;
    padding: 6px 10px;
    overflow: hidden;
    color: #f4ead1;
    background: #3c4d49;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-button.minimized {
    background: #7d5d3b;
}

.task-button.active {
    background: var(--red);
}

@media (max-width: 820px) {
    body {
        overflow: auto;
    }

    .desktop-shell {
        min-height: 100vh;
        height: auto;
        padding: 12px 12px 72px;
    }

    .memo-panel,
    .inspector-panel {
        position: relative;
        top: auto;
        right: auto;
        width: 100%;
        margin-bottom: 12px;
    }

    .memo-panel {
        min-height: auto;
    }

    .window-layer {
        position: fixed;
    }

    .dialog-window {
        width: min(330px, calc(100vw - 24px));
    }
}
