* {
  box-sizing: border-box;
}

body {
  font-family: "Inter", system-ui, sans-serif;
  margin: 0;
  padding: 0;
  background-color: #f5f7fb;
  color: #0f172a;
}

#app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.app-header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
}

.app-header p {
  margin: 0;
  color: #475569;
}

#lang-toggle {
  border: 1px solid #cbd5f5;
  background: white;
  color: #1e3a8a;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

#lang-toggle:hover {
  background-color: #1e3a8a;
  color: white;
}

.card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.audio-card {
  gap: 1.25rem;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.device-select select {
  margin-top: 0.4rem;
}

.level-meter {
  position: relative;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.level-meter #level-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  transition: width 80ms ease-out;
}

.audio-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.secondary-action {
  padding: 0.65rem 1.4rem;
  border-radius: 10px;
  border: 1px solid #dbe3ff;
  background: #f8fbff;
  color: #1e3a8a;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.secondary-action:not(:disabled):hover {
  background: #1e3a8a;
  color: white;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #dbe3ff;
  background: white;
  color: #1e3a8a;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.icon-button:hover {
  background: #1e3a8a;
  color: white;
}

.icon-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.hint {
  margin: 0;
  font-size: 0.9rem;
  color: #475569;
}

.hidden {
  display: none;
}

.temporarily-hidden {
  display: none !important;
}

.card h2 {
  margin: 0;
  font-size: 1.25rem;
  color: #1e293b;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

label span {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #1e293b;
}

input[type="text"],
input[type="password"],
select {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid #cbd5f5;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.form-options {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  border: none;
  padding: 0;
  margin: 0;
}

.form-options label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 500;
  color: #334155;
}

.form-actions {
  display: flex;
  gap: 1rem;
}

.form-actions button {
  padding: 0.85rem 1.6rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.form-actions button.primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.25);
}

.form-actions button.primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.form-actions button:not(.primary) {
  background: #e2e8f0;
  color: #334155;
}

.form-actions button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.status-panel #status-text {
  min-height: 2rem;
  display: flex;
  align-items: center;
  font-weight: 600;
  color: #2563eb;
}

#status-text[data-tone="error"] {
  color: #ef4444;
}

#status-text[data-tone="warning"] {
  color: #f59e0b;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.scroll-box {
  min-height: 160px;
  max-height: 240px;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid #dee4f7;
  background: #f8fafc;
  overflow-y: auto;
  line-height: 1.5;
  color: #1e293b;
}

.scroll-box.log {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.9rem;
  background: #0f172a;
  color: #e2e8f0;
}

.scroll-box.log .info {
  color: #38bdf8;
}

.scroll-box.log .warning {
  color: #fbbf24;
}

.scroll-box.log .error {
  color: #f87171;
}

.download-link {
  color: #38bdf8;
  text-decoration: none;
  display: inline-block;
  margin-top: 0.4rem;
}

.download-link:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  #app {
    padding: 2rem 1rem;
  }

  .audio-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .audio-actions .secondary-action,
  .audio-actions .icon-button {
    width: 100%;
  }

  .audio-actions .icon-button {
    border-radius: 12px;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions button {
    width: 100%;
  }
}
