:root {
    --primary-color: #409Eff;
    --primary-dark: #337ecc;
    --primary-light: #79bbff;
    --success-color: #67c23a;
    --warning-color: #e6a23c;
    --danger-color: #f56c6c;
    --info-color: #909399;
    --bg-color: #f0f8ff;
    --card-bg: #ffffff;
    --text-color: #303133;
    --text-secondary: #606266;
    --border-color: #dcdfe6;
    --shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* 全页水印：仅展示，不拦截操作；挖空区域由 JS 在 canvas 上 clear */
.page-watermark-layer {
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
}

.page-watermark-layer canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.main-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 10px 15px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    text-align: center;
    padding: 8px 0;
}

.header h1 {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 40px;
    border-radius: 20px;
    display: inline-block;
    font-size: 22px;
    font-weight: 600;
    width: 80%;
    max-width: 300px;
}

@media (max-width: 767px) {
    .header h1 {
        width: 90%;
        max-width: none;
    }
}

.content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
}

.left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.right-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-label {
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
    color: var(--text-color);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

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

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-dark);
}

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

.btn-success:hover:not(:disabled) {
    background-color: #5daf34;
}

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

.btn-warning:hover:not(:disabled) {
    background-color: #cf9236;
}

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

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

.login-section {
    text-align: center;
    padding: 12px 15px;
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: var(--shadow);
    width: fit-content;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.login-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
}

.login-row .section-label {
    margin-bottom: 0;
}

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

.help-section-inline {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 12px 15px;
    box-shadow: var(--shadow);
}

.help-section-inline h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.help-section-inline h3::before {
    content: '🔍';
}

.help-section-inline h4 {
    margin-top: 10px;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-color);
}

.help-content-inline ol, .help-content-inline ul {
    padding-left: 18px;
}

.help-content-inline li {
    margin-bottom: 5px;
    font-size: 12px;
    color: var(--text-secondary);
}

.help-content-inline.help-markdown li {
    font-size: inherit;
}

.help-markdown {
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-secondary);
}

.help-markdown h1,
.help-markdown h2,
.help-markdown h3,
.help-markdown h4 {
    color: var(--text-color);
    margin: 0.75em 0 0.4em;
    font-size: 1em;
    font-weight: 600;
}

.help-markdown h1:first-child,
.help-markdown h2:first-child,
.help-markdown h3:first-child,
.help-markdown h4:first-child {
    margin-top: 0;
}

.help-markdown p {
    margin: 0.5em 0;
}

.help-markdown ul,
.help-markdown ol {
    padding-left: 1.25em;
    margin: 0.4em 0;
}

.help-markdown li {
    margin-bottom: 0.35em;
}

.help-markdown code {
    font-size: 0.92em;
    background: #f5f7fa;
    padding: 0.1em 0.35em;
    border-radius: 4px;
}

.help-markdown img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.help-section .help-markdown {
    margin-bottom: 10px;
}

.message-box {
    padding: 10px 14px;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
    font-size: 16px;
    line-height: 1.5;
}

.message-box.success {
    background-color: #f0f9eb;
    color: var(--success-color);
    border: 1px solid #c2e7b0;
}

.message-box.error {
    background-color: #fef0f0;
    color: var(--danger-color);
    border: 1px solid #fbc4c4;
}

.message-box.warning {
    background-color: #fdf6ec;
    color: var(--warning-color);
    border: 1px solid #f5dab1;
}

.message-box.info {
    background-color: #f4f4f5;
    color: var(--info-color);
    border: 1px solid #e9e9eb;
}

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

.user-info {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 12px 15px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 100%;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 4px 4px;
    border-radius: 4px;
    transition: background 0.2s;
    min-width: 0;
    overflow: hidden;
}

.info-item:hover {
    background: #f5f7fa;
}

.info-item label {
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 0;
    width: auto;
    flex: 0 0 auto;
    margin-right: 2px;
    font-size: 12px;
    white-space: nowrap;
}

.info-item input {
    flex: 1;
    min-width: 0;
    padding: 5px 6px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    background-color: #f5f7fa;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    max-width: 100%;
    box-sizing: border-box;
}

.info-item.expanded input {
    white-space: normal;
    word-break: break-all;
    height: auto;
    min-height: 28px;
}

.info-item input:not([readonly]) {
    background-color: white;
    cursor: text;
}

.info-item input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.info-item input::placeholder {
    color: #c0c4cc;
}

.status-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.status-badge.reset { background-color: #f4f4f5; color: var(--info-color); }
.status-badge.pending { background-color: #fdf6ec; color: var(--warning-color); }
.status-badge.uploaded { background-color: #ecf5ff; color: var(--primary-color); }
.status-badge.qualified { background-color: #f0f9eb; color: var(--success-color); }
.status-badge.unqualified { background-color: #fef0f0; color: var(--danger-color); }
.status-badge.supplemented { background-color: #f0f9eb; color: #67c23a; }

.photo-section {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 12px 15px;
    box-shadow: var(--shadow);
}

.section-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color);
    margin-bottom: 10px;
    text-align: center;
}

.photo-upload-area {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: flex-start;
    margin-bottom: 8px;
    width: min(90vw, 720px);
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .photo-upload-area {
        width: min(90%, 720px);
    }
}

.upload-box {
    flex: 1 1 calc(50% - 5px);
    min-width: 0;
    max-width: none;
    aspect-ratio: 720 / 1104;
    height: auto;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    background-color: #fafafa;
    overflow: hidden;
    position: relative;
}

.upload-box:hover {
    border-color: var(--primary-color);
    background-color: #f5f7fa;
}

.upload-box .plus-icon {
    font-size: 40px;
    color: var(--primary-color);
    line-height: 1;
}

.upload-box .upload-text {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 5px;
}

#uploadPreviewImg {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    position: absolute;
}

.preview-box {
    flex: 1 1 calc(50% - 5px);
    min-width: 0;
    max-width: none;
    aspect-ratio: 720 / 1104;
    height: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #f5f7fa;
    position: relative;
}

.photo-compare-hint {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.45;
    width: min(90vw, 720px);
    max-width: 100%;
    margin: 0 auto 10px;
    padding: 0 8px;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .photo-compare-hint {
        width: min(90%, 720px);
    }
}

.preview-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.preview-label {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.5);
    color: white;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 3px;
}

.photo-info {
    margin-bottom: 12px;
}

.info-row {
    display: flex;
    gap: 15px;
    justify-content: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.compress-info {
    text-align: center;
    padding: 6px;
    background-color: #ecf5ff;
    border-radius: 6px;
    color: var(--primary-color);
    font-size: 12px;
    margin-bottom: 8px;
}

.warning-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: #fdf6ec;
    border-radius: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.warning-box.warning-box-process {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 12px 14px;
}

.warning-box.warning-box-error {
    background-color: #fff5f4;
    border: 1px solid #fde2e2;
}

.warning-box-top {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.warning-icon-mark {
    flex: 0 0 auto;
    font-size: 17px;
    line-height: 1.35;
    margin-top: 1px;
}

.warning-msg-red {
    margin: 0;
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    color: #e53935;
    line-height: 1.45;
}

.warning-msg-preline {
    white-space: pre-line;
}

.warning-box-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.warning-point-hint {
    font-size: 12px;
    color: #909399;
    white-space: nowrap;
}

.warning-box.error {
    background-color: #fef0f0;
}

.warning-icon {
    font-size: 14px;
}

.action-buttons {
    text-align: center;
}

.help-section {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 12px 15px;
    box-shadow: var(--shadow);
}

.help-section h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

#referenceHelpContent.help-markdown {
    font-size: 13px;
    margin-bottom: 10px;
}

.reference-img {
    text-align: center;
}

.reference-img img {
    width: 100%;
    max-width: 220px;
    aspect-ratio: 720 / 1104;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    display: flex;
    gap: 3px;
}

.spinner > div {
    width: 6px;
    height: 30px;
    background-color: var(--success-color);
    animation: stretchdelay 1.2s infinite ease-in-out;
}

.spinner .rect2 { animation-delay: -1.1s; }
.spinner .rect3 { animation-delay: -1.0s; }
.spinner .rect4 { animation-delay: -0.9s; }

@keyframes stretchdelay {
    0%, 40%, 100% { transform: scaleY(0.4); }
    20% { transform: scaleY(1.0); }
}

.loading-overlay p {
    margin-top: 15px;
    color: var(--text-secondary);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    max-width: 95vw;
    max-height: 95vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 15px;
    color: var(--text-color);
}

.close-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-color);
}

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

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 15px;
    border-top: 1px solid var(--border-color);
}

.image-editor {
    width: 95vw;
    max-width: 900px;
}

.editor-main {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.editor-canvas-wrapper {
    flex: 1;
    min-width: 280px;
    position: relative;
    background-color: #f5f7fa;
    border-radius: 8px;
    overflow: auto;
    min-height: 200px;
    max-height: min(72vh, 560px);
    display: flex;
    align-items: center;
    justify-content: center;
}

#editorCanvas {
    max-width: 100%;
    max-height: min(68vh, 520px);
    width: auto;
    height: auto;
    display: block;
    image-rendering: auto;
}

.editor-controls {
    width: 200px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group label {
    font-size: 12px;
    color: var(--text-secondary);
}

.control-group input[type="range"] {
    width: 100%;
}

.ratio-buttons {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.bg-options {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 10px 16px;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    animation: slideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast.success { background-color: var(--success-color); }
.toast.error { background-color: var(--danger-color); }
.toast.warning { background-color: var(--warning-color); }
.toast.info { background-color: var(--primary-color); }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

@media (min-width: 768px) {
    .main-container {
        max-width: 1200px;
        padding: 10px 20px;
    }
    
    .content-wrapper {
        flex-direction: row;
    }
    
    .right-panel {
        width: 300px;
    }
}

@media (max-width: 767px) {
    .editor-main {
        flex-direction: column;
    }
    
    .editor-controls {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .control-group {
        min-width: 140px;
        flex: 1;
    }
    
    .photo-upload-area {
        flex-wrap: nowrap;
    }
}
