/* ==========================================================================
   互动学习游戏生成器 - 网页版编辑器样式
   设计约定：不使用任何圆角（全局 border-radius: 0），响应式布局
   ========================================================================== */

:root {
    --primary: #2c3e50;
    --primary-dark: #22303c;
    --secondary: #3498db;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #17a2b8;
    --light: #ecf0f1;
    --dark: #343a40;

    --bg: #eef1f4;
    --panel: #ffffff;
    --border: #c9d3dd;
    --border-soft: #e1e7ec;
    --text: #22303c;
    --muted: #5f7180;
    --accent: #3498db;
    --shadow: 0 2px 6px rgba(20, 35, 50, 0.12);
}

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

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

[hidden] {
    display: none !important;
}

/* ------------------------------ 顶部操作栏 ------------------------------ */

.app-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    padding: 10px 16px;
    background: var(--primary);
    color: #fff;
    border-bottom: 3px solid var(--secondary);
    position: sticky;
    top: 0;
    z-index: 30;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: var(--secondary);
    color: #fff;
    font-weight: 700;
    letter-spacing: 1px;
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.brand-text strong {
    font-size: 15px;
    white-space: nowrap;
}

.brand-text small {
    font-size: 11px;
    color: #b9c9d6;
}

.menus {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}

.menu {
    position: relative;
}

.menu-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #fff;
    font: inherit;
    padding: 7px 12px;
    cursor: pointer;
}

.menu-btn:hover,
.menu.open .menu-btn {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.3);
}

.menu-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 270px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 4px;
    display: none;
    z-index: 40;
}

.menu.open .menu-list {
    display: block;
}

.menu-list button {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    background: transparent;
    border: 0;
    font: inherit;
    color: inherit;
    text-align: left;
    padding: 8px 10px;
    cursor: pointer;
}

.menu-list button:hover {
    background: var(--light);
}

.menu-list hr {
    border: 0;
    border-top: 1px solid var(--border-soft);
    margin: 4px 0;
}

kbd {
    font-family: Consolas, "Courier New", monospace;
    font-size: 11px;
    color: var(--muted);
    border: 1px solid var(--border);
    background: #f7f9fb;
    padding: 0 4px;
}

.app-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-left: auto;
}

/* ------------------------------- 按钮 ------------------------------- */

.btn {
    font: inherit;
    padding: 8px 14px;
    background: #f4f7fa;
    color: var(--text);
    border: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover:not(:disabled) {
    background: #e3ecf3;
    border-color: var(--secondary);
}

.btn:active:not(:disabled) {
    background: #d7e3ec;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.primary {
    background: var(--secondary);
    border-color: #2b83bd;
    color: #fff;
    font-weight: 600;
}

.btn.primary:hover:not(:disabled) {
    background: #2b83bd;
}

.btn.danger {
    background: #fdecea;
    border-color: #f0b4ae;
    color: #a83226;
}

.btn.danger:hover:not(:disabled) {
    background: #f9d7d3;
    border-color: var(--danger);
}

.btn.small {
    padding: 4px 10px;
    font-size: 12px;
}

.icon-btn {
    background: transparent;
    border: 1px solid transparent;
    color: inherit;
    font-size: 20px;
    line-height: 1;
    padding: 2px 8px;
    cursor: pointer;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    border-color: var(--border);
}

.app-bar .btn {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
}

.app-bar .btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.24);
}

.app-bar .btn.primary {
    background: var(--secondary);
    border-color: #2b83bd;
}

.app-bar .btn.primary:hover:not(:disabled) {
    background: #2b83bd;
}

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

.btn-row-wrap {
    flex-wrap: wrap;
}

.btn-row-col {
    flex-direction: column;
    align-items: stretch;
}

.btn-row-col .btn {
    width: 100%;
}

/* ------------------------------- 工作区 ------------------------------- */

.workspace {
    flex: 1;
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 14px;
    padding: 14px;
    align-items: start;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 14px;
    min-width: 0;
}

.card-title {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 2px solid var(--secondary);
    padding-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.badge {
    background: var(--secondary);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 1px 8px;
}

.badge-soft {
    background: var(--light);
    color: var(--muted);
    border: 1px solid var(--border);
    font-weight: 500;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ------------------------------- 表单 ------------------------------- */

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
    min-width: 0;
}

.field:last-child {
    margin-bottom: 0;
}

.field > label,
.field > .label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

.req {
    color: var(--danger);
    font-style: normal;
}

input[type="text"],
input[type="number"],
textarea,
select {
    font: inherit;
    color: var(--text);
    width: 100%;
    padding: 7px 9px;
    background: #fff;
    border: 1px solid var(--border);
    min-width: 0;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--secondary);
    outline-offset: -1px;
}

input[readonly] {
    background: #f4f6f8;
    color: var(--muted);
}

textarea {
    resize: vertical;
    min-height: 62px;
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 12px;
}

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

.radio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    background: #f7f9fb;
    cursor: pointer;
    font-size: 13px;
}

.radio:hover {
    border-color: var(--secondary);
}

.radio:has(input:checked) {
    background: #e6f2fb;
    border-color: var(--secondary);
    font-weight: 600;
}

.group {
    border: 1px solid var(--border);
    padding: 10px 12px 14px;
    margin: 0 0 14px;
}

.group legend {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    padding: 0 6px;
}

/* ------------------------------- 关卡列表 ------------------------------- */

.level-list {
    list-style: none;
    margin: 0 0 10px;
    padding: 0;
    border: 1px solid var(--border);
    max-height: 42vh;
    overflow: auto;
    background: #fff;
}

.level-list:focus-visible {
    outline: 2px solid var(--secondary);
    outline-offset: -1px;
}

.level-list li {
    display: block;
    margin: 0;
    list-style: none;
}

.level-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 10px;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--border-soft);
    border-left: 4px solid transparent;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.level-item:last-child {
    border-bottom: 0;
}

.level-item:hover {
    background: #f1f7fc;
}

.level-item.active {
    background: #e6f2fb;
    border-left-color: var(--secondary);
    font-weight: 700;
}

.level-item .lv-id {
    flex: 0 0 auto;
    min-width: 26px;
    text-align: center;
    background: var(--light);
    border: 1px solid var(--border);
    font-size: 12px;
    padding: 1px 4px;
}

.level-item.active .lv-id {
    background: var(--secondary);
    border-color: var(--secondary);
    color: #fff;
}

.level-item .lv-title {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.level-item .lv-type {
    flex: 0 0 auto;
    font-size: 11px;
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 0 5px;
    background: #f7f9fb;
}

.empty-hint {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 12px;
}

.empty-state {
    border: 1px dashed var(--border);
    background: #f8fafc;
    padding: 34px 18px;
    text-align: center;
    color: var(--muted);
}

.empty-state p {
    margin: 0 0 6px;
}

/* ------------------------------- 动态条目表 ------------------------------- */

.item-table {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.item-row {
    display: grid;
    gap: 8px;
    align-items: center;
}

.item-row.cols-choice {
    grid-template-columns: minmax(0, 1fr) 92px 74px;
}

.item-row.cols-drag {
    grid-template-columns: 130px minmax(0, 1fr) 152px;
}

.item-row.cols-connect {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 74px;
}

.item-row.head {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
}

.item-row.head span {
    padding-bottom: 2px;
    border-bottom: 1px solid var(--border-soft);
}

.item-row .cell-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.item-scroll {
    max-height: 320px;
    overflow: auto;
    padding-right: 4px;
}

.item-note {
    margin: 10px 0 0;
    font-size: 12px;
    color: #8a6d1e;
    background: #fff8e6;
    border: 1px solid #f0d68a;
    padding: 8px 10px;
    white-space: pre-line;
}

/* 题型提示：编辑说明 + 游戏内作答方法 */
.item-hint {
    background: #eef6fc;
    border-left: 4px solid var(--info);
    padding: 8px 12px;
    margin-bottom: 10px;
}

.hint-line {
    margin: 0;
    font-size: 12px;
    line-height: 1.6;
    color: #33556e;
}

.hint-line + .hint-line {
    margin-top: 3px;
}

.hint-line strong {
    color: var(--primary);
}

.cell-actions {
    gap: 4px;
}

.cell-actions .btn {
    min-width: 32px;
}

/* 正确顺序链 */
.order-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-top: 10px;
    padding: 8px 10px;
    background: #f7f9fb;
    border: 1px solid var(--border-soft);
    font-size: 12px;
}

.order-label {
    font-weight: 700;
    color: var(--primary);
    flex: 0 0 auto;
}

.order-chain {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
}

.order-step {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #fff;
    border: 1px solid var(--border);
    padding: 2px 7px;
}

.order-step b {
    color: #fff;
    background: var(--secondary);
    font-size: 11px;
    padding: 0 4px;
}

.order-arrow {
    color: var(--muted);
}

/* ------------------------------- 配图 ------------------------------- */

.cell-with-img {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.cell-with-img input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
}

.img-slot {
    flex: 0 0 auto;
    position: relative;
    width: 44px;
    height: 44px;
    padding: 0;
    background: #f7f9fb;
    border: 1px dashed var(--border);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.img-slot:hover {
    border-color: var(--secondary);
    background: #eef6fc;
}

.img-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.img-empty {
    font-size: 12px;
    color: var(--muted);
}

.img-badge {
    position: absolute;
    right: 0;
    bottom: 0;
    background: rgba(44, 62, 80, 0.85);
    color: #fff;
    font-size: 10px;
    padding: 0 2px;
    line-height: 1.4;
}

.img-field {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.img-meta {
    font-size: 12px;
    color: var(--muted);
}

.img-drop {
    border: 2px dashed var(--border);
    background: #f7f9fb;
    min-height: 190px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    cursor: pointer;
}

.img-drop.dragging,
.img-drop:focus-visible {
    border-color: var(--secondary);
    background: #eef6fc;
    outline: none;
}

.img-placeholder {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    max-width: 380px;
}

#image-preview {
    max-width: 100%;
    max-height: 46vh;
    object-fit: contain;
    background: #fff;
}

.item-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ------------------------------- 状态栏 ------------------------------- */

.status-bar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 6px 16px;
    background: var(--dark);
    color: #dfe6ec;
    font-size: 12px;
    position: sticky;
    bottom: 0;
    z-index: 20;
}

.status-right {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

/* ------------------------------- 模态框 ------------------------------- */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 25, 35, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 100;
}

.modal-box {
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.35);
    width: min(720px, 100%);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    color: var(--text);
}

.modal-wide {
    width: min(900px, 100%);
}

.modal-full {
    width: min(1240px, 100%);
    height: 92vh;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: var(--primary);
    color: #fff;
}

.modal-head h2 {
    margin: 0;
    font-size: 15px;
}

.modal-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-body {
    padding: 14px;
    overflow: auto;
    flex: 1;
}

.modal-body-flush {
    padding: 0;
    display: flex;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    background: #f7f9fb;
}

.doc-text {
    margin: 0;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

#preview-frame {
    flex: 1;
    width: 100%;
    min-height: 60vh;
    border: 0;
    background: #fff;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    margin-bottom: 14px;
}

.color-item {
    border: 1px solid var(--border);
    padding: 8px 10px;
    background: #f9fbfc;
}

.color-item .color-label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
}

.color-item .color-desc {
    font-size: 11px;
    color: var(--muted);
    font-weight: 400;
}

.color-line {
    display: flex;
    gap: 6px;
    align-items: center;
}

.color-line input[type="color"] {
    width: 42px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
}

.color-line input[type="text"] {
    font-family: Consolas, "Courier New", monospace;
}

.gradient-preview {
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
}

/* ---------------------------- 圆角样式控制 ---------------------------- */

.section-title {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
}

.section-title:not(:first-child) {
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid var(--border-soft);
}

.radius-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.radius-row input[type="range"] {
    flex: 1 1 auto;
    min-width: 0;
    accent-color: var(--secondary);
    height: 28px;
}

.radius-row input[type="number"] {
    flex: 0 0 84px;
    width: 84px;
}

#radius-value {
    color: var(--secondary);
    font-family: Consolas, "Courier New", monospace;
}

.chk {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 10px 0;
    font-size: 13px;
    cursor: pointer;
}

.chk input {
    margin-top: 3px;
    accent-color: var(--secondary);
}

.style-preview {
    border: 1px dashed var(--border);
    background: #f4f7fa;
    padding: 14px;
    margin-bottom: 10px;
}

.sp-panel {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 14px;
    box-shadow: 0 4px 10px rgba(20, 35, 50, 0.2);
}

.sp-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    margin-bottom: 12px;
}

.sp-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    font-size: 13px;
}

.sp-option {
    background: rgba(255, 255, 255, 0.92);
    color: var(--primary);
    padding: 10px 12px;
    margin-bottom: 10px;
}

.sp-btn {
    display: inline-block;
    background: #fff;
    color: var(--primary);
    padding: 8px 18px;
    font-weight: 700;
    font-size: 13px;
}

/* ------------------------------- 响应式 ------------------------------- */

@media (max-width: 1180px) {
    .workspace {
        grid-template-columns: 320px minmax(0, 1fr);
    }
}

@media (max-width: 980px) {
    .workspace {
        grid-template-columns: minmax(0, 1fr);
        padding: 10px;
        gap: 10px;
    }

    .level-list {
        max-height: 34vh;
    }

    .panel-main {
        order: 2;
    }
}

@media (max-width: 760px) {
    .app-bar {
        padding: 8px 10px;
    }

    .brand-text small {
        display: none;
    }

    .app-actions {
        margin-left: 0;
        width: 100%;
    }

    .app-actions .btn {
        flex: 1 1 auto;
    }

    .field-grid,
    .color-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .item-row.cols-choice,
    .item-row.cols-drag,
    .item-row.cols-connect {
        grid-template-columns: minmax(0, 1fr);
    }

    .item-row .cell-center {
        justify-content: flex-start;
    }

    .item-row.head {
        display: none;
    }

    .modal {
        padding: 0;
    }

    .modal-box,
    .modal-wide,
    .modal-full {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border: 0;
    }

    .menu-list {
        left: auto;
        right: 0;
        min-width: 240px;
    }
}

@media (max-width: 480px) {
    .brand-mark {
        width: 32px;
        height: 32px;
    }

    .brand-text strong {
        font-size: 13px;
    }

    .menu-btn {
        padding: 6px 8px;
        font-size: 13px;
    }
}
