:root {
    --aki-purple: #8e44ad;
    --aki-dark: #2c3e50;
    --aki-bg: #f8f9fa;
    --color-light: #daeaf1;
    --color-medium: #f2eada;
    --color-heavy: #f1e1e1;
    --color-od: #f3e5ab;
    --color-asagi: #cfdfdb;
    --color-smoke: #e0d1eb;
    --color-indigo: #d1d9e8;
    --color-indigo-l: #e2e8f0;
    --color-dr: #e8f5e9;
    --color-walk: #eeeeee;
    --color-sa: #dcd0ff;
    --color-select: #a2d2ff;
    --color-edit-active: #ff7675;
    --color-system-fixed: #dfe6e9;
    --color-di-red: #f5c6c6;
    --color-parry-blue: #d6eaf8;
    --color-throw: #f0f0f0;
}

body {
    font-family: sans-serif;
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--aki-bg);
    overflow: hidden;
    color: #333;
}

header {
    background: var(--aki-dark);
    color: white;
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
    z-index: 10;
    border-bottom: 2px solid var(--aki-purple);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.header-inner {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    font-size: 1.05rem;
    white-space: nowrap;
}

.manual-link {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.18);
    padding: 3px 9px;
    border-radius: 4px;
    transition: 0.2s;
    font-weight: normal;
    margin-left: 2px;
    letter-spacing: 0.01em;
}
.manual-link:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border-color: rgba(255,255,255,0.35);
}

.manual-link-en {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.15);
}
.manual-link-en:hover {
    background: rgba(255,255,255,0.18);
}

.credit-link {
    font-size: 0.72rem;
    color: #aaa;
    text-decoration: none;
    font-weight: normal;
    margin-left: 2px;
    transition: color 0.2s;
}
.credit-link:hover { color: #fff; text-decoration: underline; }

.header-controls {
    display: flex;
    gap: 14px;
    align-items: center;
}

.mode-group {
    display: flex;
    align-items: center;
    gap: 7px;
}

.group-label {
    font-size: 0.68rem;
    font-weight: bold;
    color: #95a5a6;
    text-transform: uppercase;
    white-space: nowrap;
}

.segmented-control {
    display: flex;
    background: rgba(0,0,0,0.2);
    padding: 2px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
}

.segmented-control label { cursor: pointer; user-select: none; }
.segmented-control input { display: none; }

.segmented-control span {
    display: block;
    padding: 3px 9px;
    font-size: 0.78rem;
    border-radius: 4px;
    transition: all 0.2s;
    color: #ecf0f1;
}

.segmented-control label:has(input:checked) span {
    background: var(--aki-purple);
    color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.segmented-control label:hover:not(:has(input:checked)) span {
    background: rgba(255,255,255,0.1);
}

main {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

#menu {
    position: relative;
    width: 370px;
    background: white;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    z-index: 5;
    transition: margin-left 0.3s ease;
}

#menu.closed { margin-left: -370px; }
#menu.closed #menu-toggle { left: 370px; }

.menu-scroll {
    flex: 1;
    overflow-y: auto;
    display: flex;
    padding: 5px;
    gap: 0;
}

.menu-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.menu-col:first-child { flex: 4; min-width: 0; }
.menu-col:last-child  { flex: 6; min-width: 0; }

.menu-col:last-child .move-btn { font-size: 0.74em; }

.menu-spacer { width: 8px; }

.sub-label {
    font-size: 0.82em;
    color: var(--aki-dark);
    margin: 7px 0 3px 2px;
    display: block;
    border-left: 3px solid var(--aki-purple);
    padding-left: 6px;
    font-weight: bold;
}

button.move-btn {
    cursor: pointer;
    border: 1px solid #d0d0d0;
    border-radius: 3px;
    font-size: 0.77em;
    transition: 0.1s;
    color: #444;
    background: #fff;
    min-height: 34px;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    white-space: nowrap;
}

button.move-btn:hover { filter: brightness(0.95); }

.btn-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 0 4px;
}

.btn-full { grid-column: span 2; }

.bottom-system {
    padding: 5px 8px;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
}

.section-label-mini {
    font-size: 0.64em;
    color: #999;
    margin-bottom: 2px;
    display: block;
    text-align: center;
    font-weight: bold;
}

.action-row-5 { display: grid; grid-template-columns: repeat(5,1fr); gap: 3px; margin-bottom: 4px; }
.action-row-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 3px; margin-bottom: 6px; }

.gauge-poison-container { display: flex; gap: 8px; margin-bottom: 5px; align-items: flex-end; }
.gauge-section  { flex: 6; }
.poison-section { flex: 4; }
.gauge-grid  { display: grid; grid-template-columns: repeat(4,1fr); gap: 2px; }
.poison-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 2px; }

.drive-system-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.section-label-drive {
    font-size: 0.56em;
    color: #999;
    font-weight: bold;
    text-align: center;
    line-height: 1.3;
    flex-shrink: 0;
    white-space: nowrap;
    min-width: 34px;
}

.drive-system-btns {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 4px;
    flex: 1;
}

.btn-small { min-height: 28px !important; font-size: 0.72em !important; padding: 2px 1px !important; }

.btn-light     { background-color: var(--color-light)        !important; }
.btn-medium    { background-color: var(--color-medium)       !important; }
.btn-heavy     { background-color: var(--color-heavy)        !important; }
.btn-od        { background-color: var(--color-od)           !important; }
.btn-asagi     { background-color: var(--color-asagi)        !important; }
.btn-smoke     { background-color: var(--color-smoke)        !important; }
.btn-indigo    { background-color: var(--color-indigo)       !important; }
.btn-indigo-l  { background-color: var(--color-indigo-l)     !important; }
.btn-dr        { background-color: var(--color-dr)           !important; }
.btn-walk      { background-color: var(--color-walk)         !important; }
.btn-sa        { background-color: var(--color-sa)           !important; }
.btn-fixed     { background-color: var(--color-system-fixed) !important; font-weight: bold; }
.btn-throw     { background-color: var(--color-throw)        !important; }
.btn-di-red    { background-color: var(--color-di-red)       !important; font-weight: bold; }
.btn-parry-blue{ background-color: var(--color-parry-blue)   !important; font-weight: bold; }
.btn-poison    { background-color: #dcd6f7 !important; font-weight: bold; }
.btn-dgauge    { background-color: #c2f3f3 !important; font-weight: bold; font-size: 0.68em !important; }

.special-display-bar {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-top: 1px solid #eee;
    background: #fafafa;
    gap: 6px;
    flex-shrink: 0;
}

.header-ver {
    font-size: 0.72rem;
    opacity: 0.6;
    font-weight: normal;
    margin-left: 2px;
}

.special-toggle-btn {
    width: 22px;
    height: 22px;
    background: rgba(142,68,173,0.35);
    color: rgba(255,255,255,0.8);
    border: 1px solid rgba(142,68,173,0.4);
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.65rem;
    font-weight: bold;
    flex-shrink: 0;
    transition: opacity 0.2s;
    padding: 0;
    line-height: 1;
}
.special-toggle-btn:hover { background: rgba(142,68,173,0.55); }
.special-toggle-btn.active { background: rgba(108,52,131,0.7); }

.special-panel {
    display: flex;
    gap: 4px;
}

.special-item-btn {
    padding: 3px 8px;
    border: 1px solid #bbb;
    border-radius: 3px;
    background: #fff;
    font-size: 0.68rem;
    font-weight: bold;
    cursor: pointer;
    color: #444;
    transition: 0.15s;
}
.special-item-btn:hover { background: #f0f0f0; }
.special-item-btn.active {
    background: var(--aki-purple);
    color: white;
    border-color: var(--aki-purple);
}

#canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.canvas-toolbar {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    background: rgba(255,255,255,0.95);
    padding: 5px;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid #ccc;
    display: flex;
    gap: 5px;
    z-index: 1000;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

.toolbar-btn {
    padding: 5px 9px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    font-size: 0.74em;
    cursor: pointer;
    font-weight: bold;
    white-space: nowrap;
}
.toolbar-btn:hover { background: #f5f5f5; }

.btn-danger { color: #e74c3c; border-color: #fab1a0; }
.btn-danger:hover { background: #fff5f5; }

.btn-sel-delete { color: #2980b9; border-color: #a9cce3; }
.btn-sel-delete:hover { background: #ebf5fb; }

.active-copy {
    background-color: #3498db !important;
    color: white !important;
    border-color: #2980b9 !important;
}

.toolbar-dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.toolbar-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: white;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.15);
    z-index: 2000;
    min-width: 200px;
    overflow: hidden;
}
.toolbar-dropdown-menu.open { display: block; }

.toolbar-dropdown-menu button {
    display: block;
    width: 100%;
    padding: 9px 16px;
    text-align: left;
    border: none;
    background: white;
    font-size: 0.84em;
    cursor: pointer;
    font-weight: bold;
    color: #333;
    white-space: nowrap;
}
.toolbar-dropdown-menu button:hover { background: #f0f0f0; }

.toolbar-sep-wide {
    width: 24px;
}

.parent-dropdown-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.parent-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: white;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    min-width: 180px;
    max-width: 280px;
    max-height: 45vh;
    overflow-y: auto;
    z-index: 2000;
}

.parent-dropdown-item {
    padding: 8px 13px;
    font-size: 0.86em;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: bold;
    color: #333;
}
.parent-dropdown-item:last-child { border-bottom: none; }
.parent-dropdown-item:hover { filter: brightness(0.93); }

.parent-dropdown-empty {
    padding: 10px 14px;
    font-size: 0.8em;
    color: #999;
    text-align: center;
}

#canvas {
    width: 100%;
    height: 100%;
    background-image: radial-gradient(#ddd 1px, transparent 1px);
    background-size: 20px 20px;
}

#menu-toggle {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    width: 25px;
    height: 60px;
    background: var(--aki-purple);
    color: white;
    border: none;
    border-radius: 0 5px 5px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drop-overlay {
    position: absolute;
    inset: 0;
    background: rgba(142,68,173,0.15);
    border: 3px dashed var(--aki-purple);
    border-radius: 8px;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.drop-overlay-inner {
    background: white;
    padding: 20px 40px;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--aki-purple);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.ex-hidden { display: none !important; }

.section-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    margin-bottom: 3px;
}
.section-header-flex .section-label-mini { margin: 0; }

.action-row-5 button.move-btn { font-weight: bold; font-size: 0.68em !important; }
.btn-section-condensed button.move-btn { min-height: 32px !important; }

.text-input-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.text-input-box {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.25);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 280px;
}

.text-input-box textarea {
    width: 100%;
    min-height: 64px;
    resize: vertical;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95rem;
    padding: 8px;
    font-family: sans-serif;
    box-sizing: border-box;
    outline: none;
    line-height: 1.5;
}

.text-input-box textarea:focus {
    border-color: var(--aki-purple);
    box-shadow: 0 0 0 2px rgba(142,68,173,0.15);
}

.text-input-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.text-input-actions button {
    padding: 5px 14px;
    border-radius: 4px;
    border: 1px solid #ccc;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: bold;
}

.text-input-ok {
    background: var(--aki-purple);
    color: white;
    border-color: var(--aki-purple) !important;
}

.text-input-cancel {
    background: white;
    color: #666;
}
