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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #1a1a2e;
  background: linear-gradient(180deg, #f0f4ff 0%, #e8ecf4 100%);
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px 32px;
}

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

.header h1 {
  margin: 0 0 4px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #16213e;
}

.subtitle {
  margin: 0;
  font-size: 0.8125rem;
  color: #6b7280;
}

.banner {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.875rem;
  margin-bottom: 12px;
  line-height: 1.45;
}

.banner-warn {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

.banner-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.hidden {
  display: none !important;
}

.status-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.status-label {
  font-size: 0.875rem;
  color: #6b7280;
}

.status-value {
  font-weight: 600;
  font-size: 0.9375rem;
  color: #2563eb;
}

.status-value.is-error {
  color: #dc2626;
}

.status-value.is-active {
  color: #059669;
}

.controls {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.btn {
  flex: 1;
  min-height: 52px;
  padding: 14px 20px;
  font-size: 1.0625rem;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

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

.btn-primary {
  background: #2563eb;
  color: #fff;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}

.btn-small {
  flex: none;
  min-height: 36px;
  padding: 8px 14px;
  font-size: 0.8125rem;
  font-weight: 500;
  background: #e5e7eb;
  color: #374151;
  border-radius: 8px;
}

.panel {
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.panel-header .panel-title {
  margin-bottom: 0;
}

.panel-title {
  margin: 0 0 10px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #4b5563;
}

.text-box {
  min-height: 72px;
  max-height: 200px;
  overflow-y: auto;
  padding: 12px;
  border-radius: 8px;
  font-size: 1rem;
  line-height: 1.6;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
}

.text-interim {
  background: #eff6ff;
  color: #1e40af;
  border: 1px dashed #93c5fd;
}

.text-final {
  background: #f9fafb;
  color: #111827;
  border: 1px solid #e5e7eb;
  min-height: 120px;
  max-height: 280px;
}

.text-interim:empty::before,
.text-final:empty::before {
  content: none;
}

.panel-log .log-box {
  min-height: 100px;
  max-height: 180px;
  overflow-y: auto;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  background: #1e293b;
  color: #e2e8f0;
  padding: 10px 12px;
  border-radius: 8px;
  -webkit-overflow-scrolling: touch;
}

.log-line {
  margin: 0 0 6px;
  word-break: break-all;
}

.log-line.log-error {
  color: #fca5a5;
}

.log-line.log-success {
  color: #86efac;
}

.log-time {
  color: #94a3b8;
  margin-right: 6px;
}
