* {
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Arial', system-ui, sans-serif;
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: #1a1e1a;
    color: #c8c6b0;
    overflow: hidden;
}

body.dragging #canvas {
    outline: 2px dashed #7f9c6a;
    outline-offset: -6px;
}

#layout {
    display: grid;
    grid-template-columns: 232px 1fr 320px;
    grid-template-rows: 52px 1fr 84px;
    grid-template-areas:
        "head head head"
        "left view right"
        "foot foot foot";
    height: 100vh;
    width: 100vw;
    gap: 8px;
    padding: 8px;
}

#head {
    grid-area: head;
    background: #252b25;
    border: 1px solid #3b4a3b;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 16px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

#head h1 {
    margin: 0;
    font-size: 1.12rem;
    font-weight: 500;
    letter-spacing: 1px;
    color: #d4d0b0;
    white-space: nowrap;
}

#head h1 span {
    color: #8fa87c;
    font-weight: 400;
}

#model-label {
    color: #e2e6cf;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

#info {
    color: #97a488;
    font-size: 0.78rem;
    white-space: nowrap;
}

.panel {
    background: #252b25;
    border: 1px solid #3b4a3b;
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

#left {
    grid-area: left;
    display: flex;
    flex-direction: column;
    padding: 12px;
    overflow-y: auto;
}

#view {
    grid-area: view;
    position: relative;
    padding: 0;
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    cursor: grab;
}

#canvas:active {
    cursor: grabbing;
}

#right {
    grid-area: right;
    display: flex;
    flex-direction: column;
    padding: 12px;
    min-height: 0;
}

#foot {
    grid-area: foot;
    background: #252b25;
    border: 1px solid #3b4a3b;
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.section {
    margin: 0 0 8px;
    font-size: 0.7rem;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: #8fb46a;
}

.section:not(:first-child) {
    margin-top: 14px;
}

.row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

button {
    font-family: inherit;
    font-size: 0.84rem;
    color: #d8dcc4;
    background: #313a31;
    border: 1px solid #4b5c4b;
    border-radius: 6px;
    padding: 7px 10px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}

button:hover {
    background: #3d483d;
    border-color: #6b8168;
}

button:active {
    background: #2a322a;
}

.toggle {
    flex: 1;
    text-align: left;
}

.toggle.on {
    background: #4a6b3a;
    border-color: #8fc46e;
    color: #f2f7e2;
    box-shadow: 0 0 8px rgba(130, 190, 90, 0.35) inset;
}

#cycles {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    flex: 1;
    min-height: 60px;
    padding-right: 2px;
}

.cycle-btn {
    text-align: left;
    padding: 6px 10px;
    font-size: 0.83rem;
}

.cycle-btn.on {
    background: #4a6b3a;
    border-color: #8fc46e;
    color: #f2f7e2;
}

#cycle-count {
    float: right;
    color: #97a488;
    font-size: 0.7rem;
    letter-spacing: 0;
    text-transform: none;
}

#path {
    font-size: 0.74rem;
    color: #97a488;
    word-break: break-all;
    margin: 2px 0 10px;
    line-height: 1.4;
    min-height: 2.2em;
}

#tree {
    flex: 1;
    overflow-y: auto;
    margin-top: 10px;
    min-height: 0;
    border-top: 1px solid #364536;
    padding-top: 6px;
}

.tree-row {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 6px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.83rem;
    line-height: 1.5;
    user-select: none;
}

.tree-row:hover {
    background: #313a31;
}

.arrow {
    display: inline-block;
    width: 12px;
    font-size: 0.62rem;
    color: #8fb46a;
    transition: transform 0.12s;
}

.arrow.open {
    transform: rotate(90deg);
}

.pad {
    display: inline-block;
    width: 12px;
}

.folder {
    color: #b9cfa0;
    font-weight: 500;
}

.file {
    color: #c8c6b0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file.on {
    color: #f2f7e2;
}

.tree-row:has(.file.on) {
    background: #3c5c2e;
}

.tree-empty {
    color: #7d8874;
    font-size: 0.8rem;
    padding: 8px 4px;
    line-height: 1.5;
}

#timeline {
    width: 100%;
    accent-color: #8fc46e;
    height: 20px;
    cursor: pointer;
}

.footrow {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.8rem;
    color: #a9b89a;
}

#frame-label {
    color: #e2e6cf;
    font-weight: 500;
    min-width: 300px;
}

#status {
    color: #8fb46a;
}

#tex-hint {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hint {
    color: #7d8874;
    font-size: 0.74rem;
}

#file-input, #folder-input {
    display: none;
}

label.filebtn {
    display: inline-block;
    font-size: 0.84rem;
    color: #d8dcc4;
    background: #313a31;
    border: 1px solid #4b5c4b;
    border-radius: 6px;
    padding: 7px 10px;
    cursor: pointer;
    text-align: center;
    flex: 1;
}

label.filebtn:hover {
    background: #3d483d;
    border-color: #6b8168;
}

::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

::-webkit-scrollbar-track {
    background: #1f241f;
}

::-webkit-scrollbar-thumb {
    background: #46543f;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5d7053;
}

@media (max-width: 1100px) {
    #layout {
        grid-template-columns: 200px 1fr 260px;
    }
}
