/* ============================================
   书法识文 — PWA 样式
   主题: 中国风 + 极简
   ============================================ */

:root {
    --primary: #8B5E3C;
    --primary-light: #A67B5B;
    --primary-dark: #6B4226;
    --bg: #FAF6F0;
    --card-bg: #FFFFFF;
    --text: #2C2C2C;
    --text-secondary: #888;
    --border: #E8DDD0;
    --success: #4A7C59;
    --radius: 16px;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    font-family: -apple-system, "PingFang SC", "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    -webkit-font-smoothing: antialiased;
}

body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ========== 头部 ========== */
header {
    text-align: center;
    padding: 20px 0 16px;
}

header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-dark);
    letter-spacing: 2px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ========== 步骤指示器 ========== */
.steps {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.step {
    font-size: 13px;
    padding: 6px 16px;
    border-radius: 20px;
    background: var(--border);
    color: var(--text-secondary);
    transition: all 0.3s;
}

.step.active {
    background: var(--primary);
    color: white;
}

/* ========== 主内容 ========== */
main {
    flex: 1;
}

.step-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.step-content.active {
    display: block;
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== 上传区域 ========== */
.upload-area {
    background: var(--card-bg);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.upload-icon {
    margin-bottom: 16px;
}

.upload-hint {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.upload-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ========== 按钮 ========== */
.btn-group {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 14px 28px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-appearance: none;
}

.btn:active {
    transform: scale(0.97);
}

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

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

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #ddd5c8;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 8px;
    background: var(--border);
    color: var(--text);
}

.btn-icon {
    font-size: 18px;
}

/* ========== 预览区 ========== */
.preview-area {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.image-wrapper {
    width: 100%;
    max-height: 70vh;
    overflow: hidden;
    background: #f0f0f0;
}

.image-wrapper img {
    width: 100%;
    height: auto;
    display: block;
}

.preview-actions {
    display: flex;
    gap: 12px;
    padding: 16px;
    justify-content: center;
}

/* ========== 加载动画 ========== */
.loading {
    text-align: center;
    padding: 60px 20px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.loading-sub {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ========== 结果区 ========== */
.result-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.result-header h2 {
    font-size: 18px;
    color: var(--text);
}

.result-header-actions {
    display: flex;
    gap: 8px;
}

.result-text {
    padding: 20px;
    font-size: 17px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text);
    min-height: 100px;
    outline: none;
    border-radius: 0 0 var(--radius) var(--radius);
    transition: background 0.2s;
}

.result-text[contenteditable="true"] {
    background: #FFFDF5;
    box-shadow: inset 0 0 0 2px var(--primary-light);
}

.result-text[contenteditable="true"]:focus {
    box-shadow: inset 0 0 0 2px var(--primary);
}

.result-edit-hint {
    font-size: 12px;
    color: var(--primary-light);
    text-align: center;
    padding: 4px 0 10px;
}

.result-meta {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
}

.result-actions {
    margin-top: 16px;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ========== 历史记录 ========== */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.history-header h2 {
    font-size: 20px;
    color: var(--primary-dark);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 0;
    font-size: 15px;
}

.history-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(0,0,0,0.1);
}

.history-item:active {
    transform: scale(0.99);
}

.history-item-time {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.history-item-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-all;
}

.history-item-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-end;
}

.history-item-actions .btn-sm {
    font-size: 12px;
    padding: 4px 12px;
}

/* ========== Toast 提示 ========== */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 15px;
    z-index: 100;
    max-width: 90%;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

/* ========== 底部 ========== */
footer {
    text-align: center;
    padding: 24px 0 16px;
    font-size: 12px;
    color: var(--text-secondary);
}
