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

html {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
}

:root {
  --bg-main: #f7f7f9;
  --bg-surface: #ffffff;
  --bg-elevated: #fafafa;
  --border: #e5e5ea;
  --border-focus: #d0d0d8;
  --text: #1a1a1f;
  --text-secondary: #5a5a65;
  --text-muted: #8a8a96;
  --accent: #0066ff;
  --accent-hover: #0052e6;
  --accent-light: rgba(0, 102, 255, 0.08);
  --danger: #ff3b30;
  --danger-hover: #ff5547;
  --danger-light: rgba(255, 59, 48, 0.08);
  --success: #30d158;
  --success-light: rgba(48, 209, 88, 0.1);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
  --font-display: 'Syne', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'DM+Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  background: var(--bg-main);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

.app-header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.app-logo {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo-icon {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--accent), #0044cc);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
}

.app-nav-link {
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.app-nav-link:hover {
  color: var(--text);
}

.main-content {
  max-width: 780px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  flex: 1;
}

.tool-header {
  text-align: center;
  margin-bottom: 36px;
}

.tool-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

.tool-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

.controls-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.controls-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.btn-main {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 15px 34px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-record {
  background: linear-gradient(135deg, var(--danger), #e62b27);
  color: #fff;
  box-shadow: 0 4px 20px rgba(255, 59, 48, 0.25);
}

.btn-record:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(255, 59, 48, 0.35);
}

.btn-record.recording {
  animation: recordPulse 1s ease-in-out infinite;
}

@keyframes recordPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(255, 59, 48, 0.25); }
  50% { box-shadow: 0 4px 32px rgba(255, 59, 48, 0.45); }
}

.btn-stop {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-stop:hover:not(:disabled) {
  background: var(--bg-surface);
  border-color: var(--border-focus);
  color: var(--text);
  transform: translateY(-2px);
}

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

.options-row {
  display: flex;
  justify-content: center;
  gap: 36px;
  flex-wrap: wrap;
}

.option-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-secondary);
  user-select: none;
  transition: color 0.2s;
}

.option-label:hover {
  color: var(--text);
}

.option-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.option-checkbox:hover {
  border-color: var(--border-focus);
}

.option-checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.option-checkbox:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.status-panel {
  text-align: center;
  padding: 18px 24px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  margin-bottom: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.3s;
}

.status-panel.recording {
  background: var(--danger-light);
  border-color: rgba(255, 59, 48, 0.2);
  color: var(--danger);
}

.status-panel.saved {
  background: var(--success-light);
  border-color: rgba(48, 209, 88, 0.2);
  color: var(--success);
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-focus);
  flex-shrink: 0;
}

.status-panel.recording .status-indicator {
  background: var(--danger);
  animation: statusBlink 0.8s ease-in-out infinite;
}

.status-panel.saved .status-indicator {
  background: var(--success);
}

@keyframes statusBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.preview-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
  display: none;
  box-shadow: var(--shadow-sm);
}

.preview-panel.visible {
  display: block;
  animation: slideUp 0.3s ease-out;
}

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

.preview-video {
  width: 100%;
  display: block;
  background: #000;
}

.recordings-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-sm);
}

.recordings-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 24px;
  letter-spacing: -0.01em;
}

.recordings-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 0.925rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
}

.recording-card {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  transition: all 0.2s;
}

.recording-card:hover {
  border-color: var(--border-focus);
}

.recording-card:last-child {
  margin-bottom: 0;
}

.recording-video {
  width: 160px;
  height: 96px;
  border-radius: var(--radius-sm);
  background: #000;
  flex-shrink: 0;
  object-fit: contain;
}

.recording-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recording-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.recording-meta strong {
  color: var(--text);
  font-weight: 600;
}

.recording-format {
  display: inline-block;
  padding: 2px 6px;
  background: var(--accent-light);
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  margin-left: 8px;
}

.recording-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.btn-action {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-download {
  background: var(--accent);
  color: #fff;
}

.btn-download:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.app-footer {
  padding: 24px;
  text-align: center;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  background: var(--bg-surface);
}

#site-footer-placeholder:empty {
  display: none;
}

#site-nav-placeholder {
  flex-shrink: 0;
}

#site-footer-placeholder {
  margin: 0;
  padding: 0;
  font-size: 0;
  line-height: 0;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .controls-panel {
    padding: 28px 20px;
  }

  .tool-title {
    font-size: 1.75rem;
  }

  .btn-main {
    padding: 13px 26px;
    font-size: 0.9rem;
  }

  .recording-card {
    flex-direction: column;
    align-items: stretch;
  }

  .recording-video {
    width: 100%;
    height: auto;
  }

  .recording-actions {
    flex-direction: row;
    justify-content: stretch;
  }

  .btn-action {
    flex: 1;
    justify-content: center;
  }

  .main-content {
    padding: 32px 16px 60px;
    flex: 1;
  }

  .options-row {
    gap: 24px;
  }
}