@font-face {
    font-family: 'TsangerYuYangT03';
    src: url('./lib/TsangerYuYangT-W03.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* ============ 主题变量 ============ */
:root {
    --bg: #eef1f6;
    --panel: #ffffff;
    --panel-2: #f7f9fc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #1e293b;
    --text-muted: #64748b;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --teal: #0d9488;
    --teal-hover: #0f766e;
    --amber: #d97706;
    --amber-hover: #b45309;
    --danger: #e11d48;
    --success: #16a34a;
    --header-h: 236px;
    --status-h: 40px;
    --toolbar-w: 56px;
    --inspector-w: 300px;
    --splitter-w: 6px;
    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .1);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .1), 0 2px 4px rgba(15, 23, 42, .06);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .18);
}

/* ============ 基础重置 ============ */
* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: 'TsangerYuYangT03', "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    font-size: 13px;
    color: var(--text);
    background: var(--bg);
    overflow: hidden;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

/* ============ 整体布局 ============ */
.joint-app {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
}

.app-header {
    flex: 0 0 var(--header-h);
    display: flex;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(15, 23, 42, .06);
    z-index: 20;
}

.app-body {
    flex: 1 1 auto;
    position: relative;
    min-height: 0;
}

/* ============ 导航小地图 ============ */
.mini-map {
    position: relative;
    flex: 0 0 300px;
    height: 100%;
    background: #fbfcfe;
    border-right: 1px solid var(--border);
    overflow: hidden;
}

.mini-map-label {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 5;
    padding: 2px 9px;
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, .85);
    border: 1px solid var(--border);
    border-radius: 999px;
    pointer-events: none;
}

#mini-paper {
    position: absolute;
    top: 0;
    left: 0;
}

#mini-view {
    position: absolute;
    border-radius: 2px;
}

#mini-resize {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 12px;
    height: 12px;
    cursor: nwse-resize;
    margin: 0 -6px -6px 0;
    border-radius: 50%;
    border: 2px solid var(--primary);
    background-color: #fff;
    box-shadow: var(--shadow-sm);
}

/* ============ 顶部工具栏 ============ */
.title-container {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    overflow: hidden;
}

.toolbar-top {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.brand-logo {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 12px;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.brand-sub {
    font-size: 10px;
    color: var(--text-muted);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-divider {
    width: 1px;
    height: 26px;
    background: var(--border);
    flex: 0 0 auto;
}

.field-label {
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--text-muted);
    min-width: 42px;
}

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

.toolbar-row .textarea {
    flex: 1 1 auto;
    height: 40px;
    min-width: 0;
}

.toolbar-row-grow {
    flex: 1 1 auto;
    min-height: 0;
    align-items: stretch;
}

.toolbar-row-grow .textarea {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    min-width: 0;
}

.toolbar-row-grow .field-label {
    align-self: center;
}

/* ============ 按钮 ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 13px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease, border-color .15s ease, color .15s ease;
}

.btn img {
    width: 14px;
    height: 14px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-success {
    color: #fff;
    background: var(--teal);
    border-color: var(--teal);
}

.btn-success:hover {
    background: var(--teal-hover);
    border-color: var(--teal-hover);
}

.btn-warning {
    color: #fff;
    background: var(--amber);
    border-color: var(--amber);
}

.btn-warning:hover {
    background: var(--amber-hover);
    border-color: var(--amber-hover);
}

.btn-ghost {
    color: var(--text);
    background: #fff;
}

.btn-ghost:hover {
    color: var(--primary);
    background: var(--primary-soft);
    border-color: #c7d2fe;
}

.btn-block {
    width: 100%;
}

/* ============ 输入框 / 文本域 ============ */
.input,
.textarea {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 7px 10px;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.input:focus,
.textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

.input {
    height: 32px;
}

.input-file {
    width: 120px;
}

.textarea {
    resize: none;
}

.textarea-json {
    font-size: 11px;
}

/* ============ 左侧竖向工具栏 ============ */
.left-container {
    position: absolute;
    left: 0;
    top: 0;
    bottom: var(--status-h);
    width: var(--toolbar-w);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 0;
    background: var(--panel);
    border-right: 1px solid var(--border);
    z-index: 5;
}

.tool-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--text-muted);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 9px;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, color .15s ease, background-color .15s ease, border-color .15s ease;
}

.tool-btn:hover {
    color: var(--primary);
    background: var(--primary-soft);
    border-color: #c7d2fe;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.tool-btn:active {
    transform: translateY(0);
}

/* ============ 画布区域 ============ */
.main-container {
    position: absolute;
    left: var(--toolbar-w);
    top: 0;
    right: calc(var(--inspector-w) + var(--splitter-w));
    bottom: var(--status-h);
    background: #f1f5f9;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px var(--border), 0 2px 10px rgba(15, 23, 42, .06);
}

#paper-container {
    position: absolute;
    border-radius: 6px;
    overflow: hidden;
}

#paper {
    position: absolute;
    cursor: grab;
}

#paper:active {
    cursor: grabbing;
}

/* ============ 分割面板（画布 / 属性栏） ============ */
#app-resize {
    position: absolute;
    right: var(--inspector-w);
    top: 0;
    bottom: var(--status-h);
    width: var(--splitter-w);
    background: var(--border);
    cursor: ew-resize;
    z-index: 6;
    transition: background-color .15s ease;
}

#app-resize:hover,
#app-resize:active {
    background-color: var(--primary);
}

.resize-toggle {
    position: absolute;
    left: -26px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    background-color: #fff;
    background-image: url(assets/box-arrow-in-right.svg);
    background-size: 60%;
    background-position: center;
    background-repeat: no-repeat;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: transform .15s ease, border-color .15s ease;
}

.resize-toggle:hover {
    border-color: var(--primary);
    transform: translateY(-50%) scale(1.12);
}

/* ============ 属性面板 ============ */
.right-container {
    position: absolute;
    right: 0;
    top: 0;
    bottom: var(--status-h);
    width: var(--inspector-w);
    background: var(--panel);
    border-left: 1px solid var(--border);
    overflow: hidden;
    z-index: 5;
}

.right-inner {
    height: 100%;
    padding: 14px;
    overflow-y: auto;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    padding-bottom: 8px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.panel-title::before {
    content: "";
    width: 4px;
    height: 14px;
    background: linear-gradient(180deg, #6366f1, #8b5cf6);
    border-radius: 2px;
}

.field {
    margin-bottom: 10px;
}

.field .field-label {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.field .input,
.field .textarea {
    width: 100%;
}

.field .textarea {
    min-height: 60px;
}

.panel-divider {
    height: 1px;
    background: var(--border);
    margin: 14px 0;
}

.help-text {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
}

.help-text p {
    margin: 6px 0;
}

.help-sub {
    font-weight: 700;
    color: var(--text);
    margin-top: 8px !important;
}

.op-list {
    margin: 4px 0;
    padding-left: 16px;
}

.op-list li {
    margin: 3px 0;
}

code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 11px;
    color: var(--primary);
    background: var(--primary-soft);
    padding: 1px 5px;
    border-radius: 4px;
}

/* ============ 底部状态栏 ============ */
.bottom-container {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--status-h);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    background: var(--panel);
    border-top: 1px solid var(--border);
    z-index: 20;
}

.status-dot {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, .15);
}

#status {
    margin: 0;
    font-size: 12px;
    color: var(--text);
}

.status-spacer {
    flex: 1 1 auto;
}

.status-hint {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ============ 自定义弹窗 ============ */
.app-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.app-modal.show {
    display: block;
}

.app-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(2px);
    animation: fadeIn .15s ease;
}

.app-modal-card {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 360px;
    max-width: 90vw;
    background: #fff;
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: popIn .18s ease;
}

.app-modal-head {
    padding: 14px 18px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    background: #fafbfc;
    border-bottom: 1px solid var(--border);
}

.app-modal-body {
    padding: 20px 18px;
    font-size: 13px;
    color: var(--text);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 50vh;
    overflow-y: auto;
}

.app-modal-foot {
    display: flex;
    justify-content: flex-end;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popIn {
    from { opacity: 0; transform: translate(-50%, -48%) scale(.96); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ============ 滚动条 ============ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

::-webkit-scrollbar-track {
    background: transparent;
}
