@import url("https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;600;700;800&display=swap");

/* =========================
   ROOT VARIABLES
========================= */
:root {
    --primary: #ff4a47;
    --primary-dark: #b62a2a;
    --accent: #922020;
    --toy-blue: #006aff;

    --bg: #e9e9e9;
    --surface: #ffffff;
    --border: #b7b7b7;

    --text: #1f1f1f;
    --text-secondary: #555;

    --shadow-soft: 0 2px 6px rgba(0,0,0,.08);
}

*, *::before, *::after {
    box-sizing: border-box;
}

/* =========================
   GLOBAL LAYOUT
========================= */
body {
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: Barlow, Arial, sans-serif;
    overflow: hidden;
}

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 0;
}

#studio {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* =========================
   RIBBON 
========================= */
#ribbon {
    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: space-between;

    height: 48px;
    padding: 0 12px;

    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    border-bottom: 2px solid #b30000;
    box-shadow: var(--shadow-soft);
}

#ribbonTabs {
    display: flex;
    gap: 4px;
}

.ribbon-tab {
    min-height: 30px;
    padding: 6px 16px;
    font-size: 12px;

    background: #e3e3e3;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    box-shadow: none;
}

.ribbon-tab:hover {
    background: #ececec;
}

.ribbon-tab.active {
    background: linear-gradient(180deg, var(--toy-blue), #244f90);
    color: white;
    border-color: #234d88;
}

#ribbonQuick {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ribbon-icon-btn {
    width: 36px;
    min-height: 32px;
    padding: 4px;
}

.ribbon-icon-btn img {
    width: 20px;
    height: 20px;
}

.ribbon-icon-btn-text {
    min-height: 32px;
    padding: 6px 12px;
    font-size: 11px;
}

.ribbon-play-btn {
    min-height: 32px;
    padding: 6px 18px;
    font-size: 13px;

    background: linear-gradient(180deg, #2de83d, #00a816);
    color: black;
}

.ribbon-play-btn:hover {
    background: linear-gradient(180deg, #3cf14b, #06bd1f);
}

.ribbon-play-btn:active {
    background: linear-gradient(180deg, #2cc539, #067a15);
}

.ribbon-divider {
    width: 1px;
    height: 24px;
    background: #d7d7d7;
    margin: 0 4px;
}

/* =========================
   WORKSPACE
========================= */
#workspace {
    flex: 1;
    display: flex;
    min-height: 0;
}

/* =========================
   SIDE PANELS
========================= */
#leftPanel {
    flex-shrink: 0;
    width: 260px;

    display: flex;

    background: white;
    border-right: 1px solid #cfcfcf;
}

#rightPanel {
    flex-shrink: 0;
    width: 260px;

    background: white;
    border-left: 1px solid #cfcfcf;
    overflow-y: auto;
}

/* =========================
   TOOL RAIL 
========================= */
#toolRail {
    flex-shrink: 0;
    width: 44px;

    background: #f1f1f1;
    border-right: 1px solid #cfcfcf;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
}

.rail-btn {
    width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;

    background: linear-gradient(180deg, #6b6b6b, #3a3a3a);
    border-color: #2b2b2b;
}

.rail-btn:hover {
    background: linear-gradient(180deg, #7e7e7e, #4a4a4a);
}

.rail-btn-fuse {
    background: linear-gradient(180deg, #ffb238, #c97600);
    border-color: #8a5400;
}

.rail-btn-fuse:hover {
    background: linear-gradient(180deg, #ffc15c, #d98300);
}

.rail-icon {
    font-size: 14px;
    line-height: 1;
}

.rail-divider {
    width: 26px;
    height: 1px;
    background: #cfcfcf;
    margin: 4px 0;
}

/* =========================
   VIEWPORT
========================= */
#viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

#viewport canvas {
    width: 100%;
    height: 100%;
    display: block;
}


.gizmo-axis {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 9px;
    font-weight: 800;
    color: white;
}

.gizmo-x { background: var(--primary); top: 8px; right: 8px; }
.gizmo-y { background: #2de83d; bottom: 8px; right: 14px; }
.gizmo-z { background: var(--toy-blue); bottom: 14px; left: 8px; }

/* =========================
   STATUS BAR 
========================= */
#statusBar {
    flex-shrink: 0;

    height: 26px;
    padding: 0 12px;

    display: flex;
    align-items: center;
    gap: 8px;

    background: var(--surface);
    border-top: 1px solid #cfcfcf;

    font-size: 11px;
    color: var(--text-secondary);
}

.status-divider {
    color: #ccc;
}

.status-spacer {
    flex: 1;
}




/* =========================
   TOOLBAR & HIERARCHY WINDOWS
========================= */
#toolbar,
#hierarchy {
    background: var(--surface);

    display: flex;
    flex-direction: column;
    gap: 8px;
}

#toolbar {
    flex: 1;
    min-width: 0;
    padding: 14px;
    overflow-y: auto;
}

#hierarchy {
    padding: 14px;
}

#hierarchy::before {
    content: "EXPLORER";
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* =========================
   HIERARCHY ITEMS
========================= */
.hierarchy-item {
    display: flex;
    align-items: center;
    gap: 8px;

    padding: 8px;
    cursor: pointer;

    background: #fff;
    color: #020202;
}

.hierarchy-item:hover {
    background: #ebebeb;
}

.hierarchy-item.selected {
    background: linear-gradient(180deg, var(--toy-blue), #4c5dbd);
    color: white;
}

.hierarchy-item .icon {
    width: 20px;
    text-align: center;
}

/* =========================
   BUTTONS
========================= */
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 34px;
    padding: 8px 12px;

    font-size: 12px;
    font-weight: 800;

    color: #fff;
    border: 1px solid #234d88;

    background: linear-gradient(180deg, var(--toy-blue), #244f90);

    cursor: pointer;
    box-shadow: 0 1px 0 #fff inset;
}

button:hover {
    background: linear-gradient(180deg, #2f7ae0, #1f3f73);
}

button:active {
    background: linear-gradient(180deg, #2365c0, #193561);
}

#btnPublish,
#btnRemix {
    width: 100%;
}

#btnPublish,
#btnRemix {
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    border-color: var(--accent);
}

#btnPublish:hover,
#btnRemix:hover {
    background: linear-gradient(180deg, #ff6663, var(--primary-dark));
}

/* =========================
   PART MENU AND TOYBOX GRID
========================= */
#partMenu,
#toyboxGrid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;

    max-height: 350px;
    overflow-y: auto;
}

#partMenu button {
    background: white;
    color: #222;

    border: 1px solid #cfcfcf;

    min-height: 70px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    gap: 4px;

    font-size: 24px;
    font-weight: normal;

    box-shadow: none;
}

#partMenu button span {
    font-size: 11px;
    font-weight: 700;
}

#partMenu button:hover {
    border-color: var(--toy-blue);
    background: #f4f8ff;
}

/* =========================
   PROPERTIES PANEL 
========================= */
#propertiesPanel {
    display: flex;
    flex-direction: column;
    gap: 8px;

    background: #f7f7f7;
    border: 1px solid #dcdcdc;
    padding: 10px;
}

.prop-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.prop-row label {
    flex-direction: row;
    font-size: 11px;
}

.prop-empty {
    font-size: 11px;
    color: var(--text-secondary);
    font-style: italic;
}

/* =========================
   MY PARTS
========================= */
.section-subtitle {
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    color: #999;
}

#customPartMenu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.custom-part-btn {
    width: 100%;
    justify-content: flex-start;
    gap: 8px;

    background: linear-gradient(180deg, #fff4e0, #ffe6b8);
    color: #5a3a00;
    border: 1px solid #e0b766;
    box-shadow: none;

    font-size: 11px;
}

.custom-part-btn:hover {
    background: linear-gradient(180deg, #fff0d2, #ffdca0);
}

.custom-part-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffb238, #c97600);
    flex-shrink: 0;
}

.custom-parts-empty {
    font-size: 11px;
    color: var(--text-secondary);
    padding: 8px 2px;
    line-height: 1.4;
}

/* =========================
   INPUTS
========================= */
input[type="number"],
select {
    padding: 8px;
    border: 1px solid var(--border);
    background: white;

    font-family: inherit;
    font-size: 12px;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--toy-blue);
}

#colorPicker {
    width: 60px;
    height: 30px;
    border: 1px solid var(--border);
    background: white;
    padding: 2px;
}

/* =========================
   LABELS AND FORMS
========================= */
label {
    display: flex;
    flex-direction: column;
    gap: 4px;

    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}

input[type="checkbox"] {
    margin-right: 6px;
}

/* =========================
   DIVIDERS
========================= */
hr {
    width: 100%;
    border: none;
    border-top: 1px solid #d7d7d7;
    margin: 4px 0;
}

/* =========================
   SCROLLBARS
========================= */
#toolbar::-webkit-scrollbar,
#hierarchy::-webkit-scrollbar {
    width: 8px;
}

#toolbar::-webkit-scrollbar-thumb,
#hierarchy::-webkit-scrollbar-thumb {
    background: #c0c0c0;
}

/* =========================
   SECTIONS AND HELPERS
========================= */
.section-title {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #666;
    margin-bottom: 6px;
}

.tool-section {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 9px;
}
.parts-section {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #d7d7d7;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;

    font-size: 12px;
    font-weight: 600;
}

.input-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* =========================
   TOYBOX PANEL
========================= */
#toyboxPanel {
    position: absolute;

    right: 15px;
    bottom: 15px;

    height: 50%;
    width: 380px;
    max-width: calc(100% - 30px);

    background: var(--surface);
    border: 2px solid #c9c9c9;

    box-shadow: 0 1px 0 #fff inset, var(--shadow-soft);

    padding: 12px;

    display: flex;
    flex-direction: column;
}

.panel-header {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

#toyboxSearch {
    padding: 10px;
    border: 1px solid var(--border);
    font-size: 12px;
    margin-bottom: 8px;
}

#toyboxCategories {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

#toyboxCategories button {
    min-height: 28px;
    font-size: 11px;
    padding: 4px 10px;

    background: white;
    color: var(--text);
    border: 1px solid var(--border);
}

#toyboxCategories button:hover {
    border-color: var(--toy-blue);
}

#toyboxCategories button.active {
    background: linear-gradient(180deg, var(--toy-blue), #244f90);
    color: white;
    border-color: #234d88;
}

#toyboxGrid {
    flex: 1;
    overflow-y: auto;

    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.toybox-item {
    background: white;
    border: 1px solid #d0d0d0;

    padding: 8px;
    cursor: pointer;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    gap: 4px;
}

.toybox-item:hover {
    border-color: var(--toy-blue);
    background: #f4f8ff;
}

.toybox-item img {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.toybox-item span {
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

.toybox-item small {
    font-size: 9px;
    color: var(--text-secondary);
    text-align: center;
}

.toybox-empty {
    grid-column: 1 / -1;
    padding: 24px 10px;
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
}

/* =========================
   PART ICONS
========================= */
#partMenu button img {
    width: 50px;
    height: 50px;
    object-fit: contain;
}