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

:root {
    --primary: #4A90D9;
    --danger: #E74C3C;
    --success: #27AE60;
    --bg: #F5F7FA;
    --surface: #FFFFFF;
    --text: #2C3E50;
    --text-light: #95A5A6;
    --border: #E1E8ED;
    --recording: #E74C3C;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 600px;
    margin: 0 auto;
    padding: 0;
}

/* 헤더 */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

header h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

/* 탭 바 */
.tab-bar {
    display: flex;
    flex-shrink: 0;
    background: var(--surface);
    border-bottom: 2px solid var(--border);
}

.tab {
    flex: 1;
    padding: 12px 0;
    border: none;
    background: none;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s;
}

.tab.active {
    color: var(--primary);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
}

/* 탭 콘텐츠 */
.tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
}

/* 텍스트 영역 */
.transcript-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--surface);
    -webkit-overflow-scrolling: touch;
}

#transcript {
    min-height: 100%;
    font-size: 16px;
    line-height: 1.7;
    color: var(--text);
    outline: none;
    white-space: pre-wrap;
    word-break: break-word;
    -webkit-user-select: text;
    user-select: text;
}

#transcript:empty::before {
    content: attr(placeholder);
    color: var(--text-light);
    pointer-events: none;
}

.interim-text {
    flex-shrink: 0;
    min-height: 44px;
    padding: 10px 16px;
    background: #FFF9E6;
    border-bottom: 1px solid #F0E6C8;
    color: var(--text);
    font-size: 16px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    display: none;
}

.interim-text.active {
    display: block;
}

/* 상태 바 */
.status {
    text-align: center;
    padding: 8px;
    font-size: 13px;
    color: var(--text-light);
    background: var(--bg);
    flex-shrink: 0;
    transition: all 0.3s;
}

.status.recording {
    color: var(--recording);
    font-weight: 600;
}

/* 컨트롤 버튼 */
.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    padding: 16px 16px 32px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.btn {
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

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

.btn svg {
    width: 24px;
    height: 24px;
}

.btn-clear,
.btn-save,
.btn-pause {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text-light);
}

.btn-pause {
    display: none;
}

.btn-pause.visible {
    display: flex;
}

.btn-clear:active,
.btn-save:active,
.btn-pause:active {
    background: var(--border);
}

.status.paused {
    color: #E67E22;
    font-weight: 600;
}

/* 녹음 버튼 */
.btn-record {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--surface);
    border: 4px solid var(--text-light) !important;
    position: relative;
    transition: border-color 0.3s;
}

.btn-record.recording {
    border-color: var(--recording) !important;
}

.record-icon {
    width: 32px;
    height: 32px;
    background: var(--recording);
    border-radius: 50%;
    transition: all 0.3s;
}

.btn-record.recording .record-icon {
    width: 24px;
    height: 24px;
    border-radius: 6px;
}

/* ========== 파일목록 탭 ========== */
.file-list-header {
    display: flex;
    justify-content: flex-end;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.refresh-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-light);
    font-size: 13px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.refresh-btn svg {
    width: 16px;
    height: 16px;
}

.refresh-btn:active {
    background: var(--bg);
}

.file-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0;
}

.file-list-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
    font-size: 14px;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    gap: 12px;
    -webkit-tap-highlight-color: transparent;
}

.file-item:active {
    background: var(--bg);
}

.file-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #EBF5FB;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-icon svg {
    width: 20px;
    height: 20px;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 3px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}

.file-meta-date,
.file-meta-location {
    display: flex;
    align-items: center;
    gap: 3px;
}

.file-download {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.file-download:active {
    background: var(--border);
}

.file-download svg {
    width: 18px;
    height: 18px;
}

/* 위치 정보 (저장 모달) */
.location-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-light);
    margin-top: -4px;
    margin-bottom: 4px;
}

.location-icon {
    font-size: 16px;
    flex-shrink: 0;
}

/* 설정 버튼 */
.settings-btn {
    position: fixed;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    z-index: 10;
}

.settings-btn svg {
    width: 20px;
    height: 20px;
}

/* 모달 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--surface);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal h2 {
    font-size: 18px;
    margin-bottom: 20px;
    text-align: center;
}

.input-group {
    margin-bottom: 14px;
}

.input-group label {
    display: block;
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 6px;
}

.input-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    color: var(--text);
    background: var(--bg);
}

.input-group input:focus {
    border-color: var(--primary);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.modal-cancel {
    background: var(--bg);
    color: var(--text-light);
}

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

/* 토스트 */
.toast {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    color: white;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s;
    z-index: 200;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 녹음 중 펄스 애니메이션 */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); }
    70% { box-shadow: 0 0 0 20px rgba(231, 76, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

.btn-record.recording {
    animation: pulse 1.5s infinite;
}

/* 새로고침 회전 애니메이션 */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.refresh-btn.loading svg {
    animation: spin 0.8s linear infinite;
}

/* Safe area (노치 대응) */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .controls {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}
