body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
}

/* 왼쪽 하단 컨트롤 */
.bottom-left-controls {
  position: fixed;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  transform: scale(var(--ui-scale-ratio, 1));
  transform-origin: left bottom;
}

.control-btn {
  background: transparent;
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.control-btn:hover {
  border-color: var(--accent-dark);
  color: var(--accent-dark);
}

.home-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.settings-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.control-btn .icon {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
}

:root {
  --ui-scale-ratio: 1;
}

/* 오른쪽 하단 프로그레스 */
.progress-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  text-align: right;
  z-index: 100;
  -webkit-tap-highlight-color: transparent;
  pointer-events: none;
}

.progress-number {
  font-size: 24px;
  color: var(--accent-dark);
  font-weight: 300;
  line-height: 1;
}

.progress-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

/* 메인 컨테이너 */
.container {
  max-width: var(--layout-width, 700px);
  width: 100%;
  max-height: calc(100vh - 140px);
}

/* 통계 */
.stats {
  display: flex;
  gap: 30px;
  margin-bottom: 30px;
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding-top: 8px;
}

.stat strong {
  color: var(--accent-dark);
  font-weight: 400;
}

/* 이전 텍스트 표시 영역 */
.text-display {
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  padding: 20px 0;
  margin-bottom: 30px;
  min-height: 140px;
  max-height: 260px;
  overflow-y: auto;
  font-family: var(--font-writing);
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.text-display__placeholder {
  color: var(--text-tertiary);
  font-style: italic;
}

.text-display::-webkit-scrollbar {
  width: 1px;
}

.text-display::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

.text-display::-webkit-scrollbar-thumb {
  background: var(--border-medium);
}

/* 작성 영역 */
.writing-input {
  width: 100%;
  padding: 0;
  background: transparent;
  border: none;
  font-family: var(--font-writing);
  font-size: 14px;
  line-height: 1.8;
  min-height: clamp(200px, 40vh, 480px);
  resize: none;
  font-weight: 300;
  color: var(--accent-dark);
}

.writing-input:focus {
  outline: none;
}

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

/* 컨트롤 버튼들 */
.writing-controls {
  margin-top: 40px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.pause-btn,
.done-btn {
  background: transparent;
  border: 1px solid var(--border-medium);
  padding: 12px 24px;
  font-size: 12px;
  font-family: "Courier New", "Noto Serif KR", monospace, serif;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.pause-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-tertiary);
}

.done-btn {
  color: var(--text-placeholder);
  cursor: not-allowed;
}

.done-btn:not(:disabled) {
  background: var(--accent-dark);
  color: var(--bg-primary);
  border-color: var(--accent-dark);
  cursor: pointer;
}

.done-btn:not(:disabled):hover {
  background: var(--accent-black);
  border-color: var(--accent-black);
}

/* Dark mode: soften active Complete button */
html[data-theme="dark"] .done-btn:not(:disabled) {
  background: #333333;
  border-color: #f0f0f0;
  color: #f8f8f8;
}

html[data-theme="dark"] .done-btn:not(:disabled):hover {
  background: #2a2a2a;
  border-color: #ffffff;
  color: #ffffff;
}

/* 목표 달성 힌트 */
.goal-hint {
  text-align: center;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 15px;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity 0.5s ease;
}

.goal-hint.visible {
  opacity: 1;
}

/* 완료 화면 */
.completion-screen {
  display: none;
  max-width: 700px;
  width: 100%;
}

.completion-screen.active {
  display: block;
}

.completion-message {
  text-align: center;
  padding: 40px 0;
  margin-bottom: 40px;
}

.completion-message h2 {
  font-size: 14px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 10px;
}

.completion-message p {
  font-size: 12px;
  color: var(--text-secondary);
}

/* 최종 텍스트 */
.final-text h3 {
  font-size: 12px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 20px;
  color: var(--text-secondary);
}

.final-content {
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  padding: 20px 0;
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 30px;
  font-family: var(--font-writing);
  font-weight: 300;
}

/* 액션 버튼들 */
.action-buttons {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.action-btn {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--accent-dark);
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 12px;
  font-family: "Courier New", "Noto Serif KR", monospace, serif;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.action-btn:hover {
  background: var(--accent-dark);
  color: var(--bg-primary);
}

/* 반응형 */
@media (max-width: 640px) {
  body {
    padding: 10px;
  }

  .container,
  .completion-screen {
    max-width: 100%;
    min-height: calc(100vh - 120px);
  }

  .stats {
    gap: 15px;
    font-size: 11px;
  }

  .text-display {
    min-height: 150px;
    max-height: 240px;
  }

  .writing-input {
    font-size: 16px;
    min-height: clamp(260px, 55vh, 440px);
  }

  .bottom-left-controls {
    bottom: 15px;
    left: 15px;
  }

  .progress-container {
    bottom: 15px;
    right: 15px;
  }
}

@supports (padding: env(safe-area-inset-bottom)) {
  .progress-container {
    right: calc(20px + env(safe-area-inset-right));
    bottom: calc(20px + env(safe-area-inset-bottom));
  }

  @media (max-width: 640px) {
    .progress-container {
      right: calc(15px + env(safe-area-inset-right));
      bottom: calc(15px + env(safe-area-inset-bottom));
    }
  }
}
