/* ── Obsidian Terminal — 메일 머지 웹 ── */

:root {
    /* 배경 계층 */
    --bg: #070b11;
    --panel: #0e1520;
    --panel-raised: #14203a;
    --panel-soft: #1c2f4e;
    --border: #243b5c;

    /* 액센트 */
    --accent: #00f0c0;
    --accent-hover: #33ffd6;
    --accent-dim: #0fb88a;
    --accent-glow: rgba(0, 240, 192, 0.15);

    /* 시맨틱 */
    --danger: #ff5068;
    --warning: #ffc64d;
    --good: #3dfcb5;

    /* 스탯 틴트 */
    --stat-total: rgba(0, 240, 192, 0.07);
    --stat-success: rgba(61, 252, 181, 0.07);
    --stat-fail: rgba(255, 80, 104, 0.07);

    /* 텍스트 */
    --text-1: #e8f0ff;
    --text-2: #8ea8cc;
    --text-3: #5a7499;

    /* 로그 */
    --log-bg: #060a10;

    /* 폰트 */
    --font-display: 'Outfit', 'Noto Sans KR', sans-serif;
    --font-body: 'Noto Sans KR', 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

body[data-theme="light"] {
    --bg: #f3f6fb;
    --panel: #ffffff;
    --panel-raised: #f7f9fd;
    --panel-soft: #eaf0fb;
    --border: #cfd9ea;
    --accent: #007a67;
    --accent-hover: #00997f;
    --accent-dim: #bce8de;
    --accent-glow: rgba(0, 122, 103, 0.12);
    --danger: #d63854;
    --warning: #af7b00;
    --good: #12825f;
    --stat-total: rgba(0, 122, 103, 0.08);
    --stat-success: rgba(18, 130, 95, 0.08);
    --stat-fail: rgba(214, 56, 84, 0.08);
    --text-1: #0f1e33;
    --text-2: #2d4568;
    --text-3: #6d83a3;
    --log-bg: #eef3fa;
}

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

body {
    background: var(--bg);
    color: var(--text-1);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* ── 스크롤바 ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── 레이아웃 ── */
.shell {
    max-width: 780px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

.content-scroll {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

/* ── 헤더 ── */
.header-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideDown 0.5s ease;
}

.header-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-1);
}

.header-subtitle {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 2px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle {
    background: var(--panel-soft);
    color: var(--text-1);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.15s;
}

.theme-toggle:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.status-chip {
    background: var(--accent);
    color: var(--bg);
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    padding: 5px 14px;
    border-radius: 999px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* ── 카드 ── */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    animation: fadeUp 0.4s ease backwards;
}

.card[data-stagger="1"] { animation-delay: 0.05s; }
.card[data-stagger="2"] { animation-delay: 0.1s; }
.card[data-stagger="3"] { animation-delay: 0.15s; }
.card[data-stagger="4"] { animation-delay: 0.2s; }

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 8px;
}

.card-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-glow);
    border-radius: 8px;
    font-size: 15px;
    flex-shrink: 0;
}

.card-title {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-1);
    flex: 1;
}

.badge {
    background: var(--accent-dim);
    color: var(--bg);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
}

.card-body {
    padding: 4px 16px 14px;
}

/* ── 입력 ── */
.input {
    width: 100%;
    background: var(--panel-raised);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-1);
    font-family: var(--font-body);
    font-size: 13px;
    padding: 10px 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 8px;
}

.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input::placeholder { color: var(--text-3); }

.input-small {
    width: 80px;
    text-align: center;
    margin-bottom: 0;
}

/* ── 드롭존 ── */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 28px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.drop-text {
    color: var(--text-2);
    font-size: 13px;
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.file-info {
    color: var(--text-3);
    font-size: 12px;
    margin-top: 8px;
}

/* ── 옵션 행 ── */
.options-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.option-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.option-label,
.option-unit {
    color: var(--text-2);
    font-size: 12px;
}

/* ── 체크박스 ── */
.checkbox-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-1);
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.checkbox-wrap input { display: none; }

.checkbox-visual {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.checkbox-wrap input:checked + .checkbox-visual {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-wrap input:checked + .checkbox-visual::after {
    content: '✓';
    color: var(--bg);
    font-size: 12px;
    font-weight: 700;
}

/* ── 수신자 목록 ── */
.recipient-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.recipient-item {
    background: var(--panel-raised);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    transition: border-color 0.15s;
    cursor: default;
}

.recipient-item:hover { border-color: var(--border); }

.recipient-email {
    color: var(--text-1);
    font-weight: 500;
}

.recipient-subject {
    color: var(--text-2);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recipient-attach-meta {
    color: var(--text-3);
    font-size: 11px;
    margin-top: 4px;
}

/* ── 스탯 타일 ── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    animation: fadeUp 0.4s ease 0.25s backwards;
}

.stat-tile {
    background: var(--panel-raised);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 12px;
    text-align: center;
}

.stat-total { background: var(--stat-total); }
.stat-success { background: var(--stat-success); }
.stat-fail { background: var(--stat-fail); }

.stat-value {
    display: block;
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
}

.stat-total .stat-value { color: var(--accent); }
.stat-success .stat-value { color: var(--good); }
.stat-fail .stat-value { color: var(--danger); }

.stat-label {
    display: block;
    color: var(--text-2);
    font-size: 11px;
    margin-top: 4px;
}

/* ── 액션 버튼 ── */
.action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: fadeUp 0.4s ease 0.3s backwards;
}

.action-right {
    display: flex;
    gap: 8px;
}

.btn {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

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

.btn-secondary {
    background: var(--panel-soft);
    color: var(--text-1);
}

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

.btn-send {
    background: var(--accent);
    color: var(--bg);
    padding: 12px 28px;
    font-size: 14px;
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-send:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: 0 0 30px rgba(0, 240, 192, 0.25);
    transform: translateY(-1px);
}

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

.btn-danger:hover:not(:disabled) {
    background: #ff7b86;
}

/* ── 프로그레스 ── */
.progress-block {
    animation: fadeUp 0.4s ease 0.35s backwards;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--panel);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.4s ease, background-color 0.3s;
    box-shadow: 0 0 12px var(--accent-glow);
}

.progress-label {
    color: var(--text-3);
    font-size: 12px;
    margin-top: 6px;
}

/* ── 로그 ── */
.log-panel {
    background: var(--log-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    min-height: 200px;
    max-height: 340px;
    overflow-y: auto;
    animation: fadeUp 0.4s ease 0.4s backwards;
}

.log-content {
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.7;
}

.log-line {
    white-space: pre-wrap;
    word-break: break-all;
}

.log-line.accent { color: var(--accent); }
.log-line.success { color: var(--good); }
.log-line.fail { color: var(--danger); }
.log-line.warn { color: var(--warning); }
.log-line.info { color: var(--text-2); }

/* ── 모달 ── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 90%;
    max-width: 680px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: scaleUp 0.25s ease;
}

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

.modal-header h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-2);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    transition: color 0.15s;
}

.modal-close:hover { color: var(--danger); }

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

.preview-meta p {
    font-size: 12px;
    color: var(--text-2);
    margin-bottom: 4px;
}

.preview-meta p strong {
    color: var(--text-1);
}

.preview-body {
    background: var(--panel-raised);
    border-radius: 10px;
    padding: 16px;
    margin-top: 12px;
    font-size: 13px;
    white-space: pre-wrap;
    line-height: 1.7;
    color: var(--text-1);
    max-height: 400px;
    overflow-y: auto;
}

.modal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

.modal-counter {
    font-size: 12px;
    color: var(--text-2);
}

/* ── 애니메이션 ── */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes scaleUp {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 20px var(--accent-glow); }
    50% { box-shadow: 0 0 35px rgba(0, 240, 192, 0.3); }
}

/* ── 서명·첨부 업로드 ── */
.file-upload-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-compact {
    padding: 8px 16px;
    font-size: 12px;
    border-radius: 8px;
}

.upload-status {
    color: var(--text-3);
    font-size: 12px;
    flex: 1;
}

.badge-optional {
    background: var(--panel-soft);
    color: var(--text-3);
}

.badge-done {
    background: var(--accent-dim);
    color: var(--bg);
}

.attachment-list {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.attachment-item {
    background: var(--panel-raised);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 11px;
    color: var(--text-2);
}

.attachment-assign-wrap {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}

.attachment-assign-toolbar {
    background: var(--panel-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 8px;
}

.attachment-assign-guide {
    font-size: 12px;
    color: var(--text-2);
    margin-bottom: 8px;
}

.attachment-filter-input {
    margin-bottom: 8px;
}

.attachment-bulk-label {
    display: block;
    color: var(--text-2);
    font-size: 11px;
    margin-bottom: 6px;
}

.attachment-tool-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.attachment-assign-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attachment-assign-row {
    background: var(--panel-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
}

.attachment-assign-label {
    display: block;
    color: var(--text-2);
    font-size: 11px;
    margin-bottom: 6px;
}

.attachment-assign-select {
    width: 100%;
    min-height: 72px;
    background: var(--panel-soft);
    color: var(--text-1);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px;
    font-size: 12px;
}

.attachment-checkbox-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 6px;
}

.attachment-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--panel-soft);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 12px;
    color: var(--text-1);
}

.attachment-checkbox-item input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent-dim);
}

.attachment-bulk-checklist {
    margin-bottom: 8px;
}

.attachment-assign-empty {
    color: var(--text-3);
    font-size: 12px;
    padding: 10px 6px;
}

/* ── 반응형 ── */
@media (max-width: 600px) {
    .shell { padding: 12px 10px 30px; }
    .header-card { flex-direction: column; gap: 10px; text-align: center; }
    .stats-row { grid-template-columns: 1fr; }
    .action-row { flex-direction: column; gap: 8px; }
    .action-right { width: 100%; justify-content: stretch; }
    .action-right .btn { flex: 1; }
    .options-row { flex-direction: column; align-items: flex-start; }
    .modal { width: 96%; max-height: 90vh; }
    .file-upload-row { flex-direction: column; align-items: flex-start; }
}
