/* ============================================================
   智能润色页面样式（view-polish / view-deai 共用）
   · 依赖 main.css 主题变量（--brand / --bg / --card …），与首页一致
   · 全宽双栏：头部 / 原文输入 + 润色结果 / 底部控制区
   ============================================================ */

.polish-main {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
}

.polish-shell {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--card);
    overflow: hidden;
}

/* ---------- 头部 ---------- */
.polish-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--card);
    flex-shrink: 0;
}
.polish-header-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
/* 头部图标做成品牌色软底徽标，标题层级更清楚 */
.polish-header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--r-btn);
    font-size: 15px;
    color: var(--brand);
    background: var(--brand-soft);
    flex-shrink: 0;
}
.polish-header-left h2 { margin: 0; font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; }
.polish-header-sep { color: var(--muted); font-size: 13px; }
.polish-header-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.polish-header-right { display: flex; align-items: center; gap: 0; flex-shrink: 0; }
/* 头部控件分组：角色卡 / 生成设置（深度+模型），组间用细分隔线区分，避免一长串控件糊在一起 */
.polish-header-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
}
.polish-header-group + .polish-header-group { border-left: 1px solid var(--border); }
.polish-header-group:first-child { padding-left: 0; }
.polish-header-group:last-child { padding-right: 0; }
.polish-depth-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.polish-depth-select,
.polish-style-select,
.polish-model-select {
    padding: 6px 10px;
    font-size: 13px;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-btn);
    outline: none;
    cursor: pointer;
}
.polish-depth-select { min-width: 76px; }
.polish-style-select { min-width: 96px; }
.polish-model-select { min-width: 130px; }
.polish-depth-select:focus,
.polish-style-select:focus,
.polish-model-select:focus { border-color: var(--brand); }

/* 自定义角色卡输入框 */
.polish-role-custom {
    min-width: 160px;
    padding: 6px 10px;
    font-size: 13px;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-btn);
    outline: none;
}
.polish-role-custom:focus { border-color: var(--brand); }
.polish-role-custom[hidden] { display: none; }

/* ---------- 双栏主体 ---------- */
/* 背景用首页同款暖米底（--bg），让白色面板浮在上面 */
.polish-body {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg);
}

.polish-pane {
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-card);
    overflow: hidden;
    /* 与首页卡片同款软投影，从暖米底上抬升 */
    box-shadow: var(--shadow-soft);
}
.polish-pane-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--card-2);
    flex-shrink: 0;
}
.polish-pane-title { font-size: 13px; font-weight: 700; color: var(--text); }
.polish-char-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.polish-mini-btn {
    padding: 4px 10px;
    font-size: 12px;
    color: var(--text-sub);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: all var(--t);
}
.polish-mini-btn:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.polish-mini-btn:disabled { opacity: .5; cursor: not-allowed; }

/* 结果区工具栏（字号 + 复制等），靠右与字数统计同一行 */
.polish-head-tools { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* 字号切换：只在这里定义档位变量，正文类名各自消费（见 .polish-output-text / .deai-output-text） */
.polish-font-size {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    overflow: hidden;
}
.polish-fs-btn {
    padding: 3px 8px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-sub);
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--t);
}
.polish-fs-btn:last-child { border-right: none; }
.polish-fs-btn:hover { color: var(--brand); background: var(--brand-soft); }
.polish-fs-btn.active { color: var(--brand); font-weight: 700; background: var(--brand-soft); }

.polish-output.fs-s { --reading-fs: 13px; }
.polish-output.fs-m { --reading-fs: 15px; }
.polish-output.fs-l { --reading-fs: 18px; }

.polish-input {
    flex: 1 1 auto;
    min-height: 0;
    resize: none;
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text);
    background: var(--card);
    border: none;
    outline: none;
    box-sizing: border-box;
}
.polish-input::placeholder { color: var(--muted); }

/* 提要求：本次润色的自由指令（选填），发送时作为独立提示块拼进用户消息 */
.polish-req-row {
    flex-shrink: 0;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    background: var(--card-2);
}
.polish-req-label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-sub);
}
.polish-req-input {
    width: 100%;
    box-sizing: border-box;
    min-height: 52px;
    max-height: 120px;
    resize: vertical;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 12.5px;
    line-height: 1.65;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.polish-req-input::placeholder { color: var(--muted); }
.polish-req-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.polish-input-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.polish-output {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text);
    /* 用 flex 列容器让空状态能整体垂直居中（.polish-empty 的 margin:auto 依赖它） */
    display: flex;
    flex-direction: column;
}
/* 结果正文：中文小说排版——首行缩进 2 字、段间距、舒适行距，并限制阅读宽度居中 */
.polish-output-text {
    max-width: 42em;
    margin: 0 auto;
    font-size: var(--reading-fs, 14px);
    line-height: 1.9;
    word-break: break-word;
}
.polish-output-text p {
    margin: 0 0 .8em;
    text-indent: 2em;
}
.polish-output-text p:last-child { margin-bottom: 0; }

/* 空状态：图标 + 标题 + 引导文案 */
.polish-empty {
    margin: auto;
    text-align: center;
    color: var(--muted);
    padding: 40px 20px;
}
.polish-empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    border-radius: 50%;
    font-size: 22px;
    color: var(--brand);
    background: var(--brand-soft);
}
.polish-empty p { margin: 0 0 8px; font-size: 14px; color: var(--text-sub); }
.polish-empty .polish-empty-hint { font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.8; }

.polish-output-cursor {
    display: inline-block;
    width: 8px;
    height: 16px;
    background: var(--brand);
    vertical-align: -3px;
    margin-left: 2px;
    animation: polish-blink 1s steps(1) infinite;
}
@keyframes polish-blink { 50% { opacity: 0; } }

/* ---------- 底部控制区 ---------- */
.polish-composer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px 12px;
    border-top: 1px solid var(--border);
    background: var(--card);
    flex-shrink: 0;
}
.polish-composer-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.polish-status-cluster {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 2px;
}
.polish-status { font-size: 12.5px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.polish-cost { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.polish-control-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text-sub);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r-btn);
    cursor: pointer;
    transition: all var(--t);
}
.polish-control-btn:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.polish-control-btn svg { width: 15px; height: 15px; }
.polish-control-icon { display: inline-flex; align-items: center; }

.polish-stop-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 13px;
    color: #fff;
    background: var(--btn-danger);
    border: none;
    border-radius: var(--r-btn);
    cursor: pointer;
    transition: opacity .15s;
}
.polish-stop-btn:hover { opacity: .85; }
/* 这两个类显式声明了 display，会覆盖 hidden 属性，必须补回隐藏规则 */
.polish-control-btn[hidden],
.polish-stop-btn[hidden] { display: none; }

/* 开始按钮用首页同款品牌渐变 + 品牌阴影 */
.polish-start-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 26px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--btn-primary) 0%, var(--brand-hover) 100%);
    border: none;
    border-radius: var(--r-btn);
    cursor: pointer;
    box-shadow: var(--shadow-brand);
    transition: background var(--t), opacity var(--t), transform var(--t);
    flex-shrink: 0;
}
.polish-start-btn:hover { background: linear-gradient(135deg, var(--brand-hover) 0%, var(--btn-primary) 100%); transform: translateY(-1px); }
.polish-start-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
    .polish-body { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
}
@media (max-width: 768px) {
    .polish-main { height: calc(100vh - 56px - 16px); }
    .polish-header { padding: 8px 12px; flex-wrap: wrap; gap: 8px; }
    .polish-header-sub { display: none; }
    /* 窄屏下控件换行后，组间竖向分隔线显得割裂，去掉；压缩控件宽度避免溢出 */
    .polish-header-group { padding: 0 8px; flex-wrap: wrap; row-gap: 6px; }
    .polish-header-group + .polish-header-group { border-left: none; }
    .polish-header-group:first-child { padding-left: 0; }
    .polish-depth-select { min-width: 0; max-width: 80px; }
    .polish-style-select { min-width: 0; max-width: 104px; }
    .polish-model-select { min-width: 0; max-width: 130px; }
    .polish-body { padding: 8px; gap: 8px; }
    .polish-input { padding: 12px 12px; }
    .polish-output { padding: 12px 12px; }
    .polish-composer { padding: 8px 12px 10px; flex-wrap: wrap; }
    .polish-status-cluster { flex-basis: 100%; order: 3; }
}
