/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  background: #0a0a0f;
  color: #e0e0e8;
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}

/* ===== Header ===== */
.header {
  text-align: center;
  padding: 2rem 1rem 1.2rem;
  background: linear-gradient(135deg, #12121a 0%, #1a1a2e 100%);
  border-bottom: 1px solid #2a2a3e;
}

.header__title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, #f472b6, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header__subtitle {
  margin-top: 0.3rem;
  font-size: 0.9rem;
  color: #888;
}

/* ===== Main ===== */
.main {
  padding: 1rem 10%;
}

/* ===== Card ===== */
.card {
  margin-bottom: 1rem;
  padding: 1.2rem;
  background: #14141e;
  border: 1px solid #2a2a3e;
  border-radius: 12px;
}

.card__title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.8rem;
}

/* ===== Input ===== */
.input-text {
  width: 100%;
  padding: 0.8rem 1rem;
  background: #1a1a28;
  border: 1px solid #3a3a50;
  border-radius: 8px;
  color: #e0e0e8;
  font-size: 1.1rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 60px;
}

.input-text:focus {
  outline: none;
  border-color: #818cf8;
}

.input-text::placeholder {
  color: #555;
}

.input-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.8rem;
  flex-wrap: wrap;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.6rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn--speak {
  background: linear-gradient(135deg, #818cf8, #f472b6);
  color: #fff;
  flex: 1;
  min-height: 48px;
  font-size: 1.1rem;
}

.btn--speak:hover {
  opacity: 0.9;
}

.btn--speak.speaking {
  background: #ef4444;
  animation: pulse-speak 1.2s ease-in-out infinite;
}

@keyframes pulse-speak {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
}

.btn--stop {
  background: #ef4444;
  color: #fff;
  min-height: 48px;
}

.btn--repeat {
  background: transparent;
  border: 1px solid #818cf8;
  color: #818cf8;
  min-height: 48px;
}

.btn--repeat:hover {
  background: rgba(129, 140, 248, 0.1);
}

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

/* ===== Quick Phrases ===== */
.phrase-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.phrase-btn {
  padding: 0.5rem 1rem;
  background: #1a1a28;
  border: 1px solid #2a2a3e;
  border-radius: 20px;
  color: #ccc;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.phrase-btn:hover {
  border-color: #818cf8;
  background: #1e1e30;
}

.phrase-btn:active {
  background: #2a2a40;
}

.phrase-btn--custom {
  border-color: #818cf8;
  position: relative;
}

.phrase-btn--deleting {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}

.phrase-add {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.phrase-add__input {
  flex: 1;
  padding: 0.5rem 0.8rem;
  background: #1a1a28;
  border: 1px solid #3a3a50;
  border-radius: 8px;
  color: #e0e0e8;
  font-size: 0.9rem;
}

.phrase-add__input:focus {
  outline: none;
  border-color: #818cf8;
}

.phrase-add__btn {
  background: #818cf8;
  color: #fff;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

/* ===== Settings ===== */
.setting-row {
  margin-bottom: 1rem;
}

.setting-row:last-child {
  margin-bottom: 0;
}

.setting-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ccc;
  margin-bottom: 0.3rem;
}

.setting-select {
  width: 100%;
  padding: 0.5rem 0.8rem;
  background: #1a1a28;
  border: 1px solid #3a3a50;
  border-radius: 6px;
  color: #e0e0e8;
  font-size: 0.9rem;
  appearance: none;
}

.setting-slider-wrap {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.setting-slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #2a2a3e;
  border-radius: 3px;
  outline: none;
}

.setting-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #818cf8;
  cursor: pointer;
}

.setting-value {
  font-size: 0.85rem;
  color: #888;
  min-width: 40px;
  text-align: right;
}

.setting-hint {
  font-size: 0.75rem;
  color: #555;
  margin-top: 0.2rem;
}

.setting-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.toggle-btn {
  padding: 0.3rem 1rem;
  border-radius: 20px;
  border: 1px solid #3a3a50;
  background: #1a1a28;
  color: #888;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.toggle-btn[data-active="true"] {
  background: rgba(129, 140, 248, 0.2);
  border-color: #818cf8;
  color: #818cf8;
}

/* ===== History ===== */
.history-list {
  max-height: 200px;
  overflow-y: auto;
}

.history-empty {
  font-size: 0.85rem;
  color: #555;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #1a1a28;
  cursor: pointer;
}

.history-item:hover {
  background: #1a1a28;
  border-radius: 6px;
  padding-left: 0.4rem;
}

.history-item__text {
  flex: 1;
  font-size: 0.9rem;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item__time {
  font-size: 0.7rem;
  color: #555;
  flex-shrink: 0;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: #555;
  font-size: 0.8rem;
  border-top: 1px solid #1a1a2e;
}

/* ===== Utility ===== */
.hidden {
  display: none !important;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .header {
    padding: 1.5rem 1rem 1rem;
  }

  .header__title {
    font-size: 1.6rem;
  }

  .main {
    padding: 0.8rem 5%;
  }

  .card {
    padding: 1rem;
  }

  .input-text {
    font-size: 1rem;
  }

  .btn--speak {
    font-size: 1rem;
    padding: 0.8rem 1rem;
  }
}

/* ===== Safe area (notch対応) ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .footer {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  }
}
