:root {
  color-scheme: light;
  --bg: #f7f3ea;
  --ink: #18272a;
  --muted: #637174;
  --panel: #ffffff;
  --line: #d8dedb;
  --brand: #245c63;
  --brand-2: #2f7f72;
  --danger: #a23d35;
  --shadow: 0 18px 44px rgba(31, 45, 48, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app {
  width: min(720px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar,
.pack-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.quick-actions,
.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 14px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.segment,
.icon-btn,
.small-btn,
.save-btn {
  border: 0;
  border-radius: 8px;
  min-height: 46px;
  padding: 0 16px;
  background: #e7eeeb;
  color: var(--ink);
  font-weight: 700;
}

.segment.active {
  background: var(--brand);
  color: #fff;
}

.icon-btn {
  background: #fff;
  border: 1px solid var(--line);
}

.hero {
  flex: 1;
  min-height: 390px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 24px;
  text-align: center;
}

.direction,
.status {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
}

.record {
  width: min(72vw, 320px);
  aspect-ratio: 1;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: radial-gradient(circle at 50% 35%, var(--brand-2), var(--brand));
  box-shadow: var(--shadow);
  font-size: clamp(30px, 8vw, 48px);
  font-weight: 800;
  letter-spacing: 0;
}

.record.recording {
  background: radial-gradient(circle at 50% 35%, #c8594f, var(--danger));
  transform: scale(0.98);
}

.result,
.pack {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.result-block {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.result-block:last-of-type {
  border-bottom: 0;
}

.source-text,
.translated-text {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.source-text {
  font-size: 22px;
}

.translated-text {
  font-size: clamp(30px, 8vw, 46px);
  font-weight: 800;
}

.actions,
.pack-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.actions {
  margin-top: 14px;
}

.small-btn,
.save-btn {
  background: var(--brand);
  color: #fff;
}

.pack {
  position: fixed;
  inset: 12px;
  z-index: 10;
  overflow: auto;
}

.pack h1,
.pack-item h2 {
  margin: 0;
}

.pack-form {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.pack-form input,
.pack-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfb;
  color: var(--ink);
}

.pack-form textarea {
  min-height: 110px;
  resize: vertical;
}

.pack-list {
  display: grid;
  gap: 12px;
}

.pack-item {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfb;
}

.pack-item p {
  margin: 8px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.danger {
  background: #f2dfdc;
  color: var(--danger);
}

.big-card {
  position: fixed;
  inset: 0;
  z-index: 20;
  padding: 18px;
  background: rgba(24, 39, 42, 0.38);
  display: grid;
  place-items: center;
}

.big-card-inner {
  width: min(680px, 100%);
  max-height: 90svh;
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.big-card-inner p {
  margin: 20px 0 0;
  font-size: clamp(32px, 9vw, 64px);
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.hidden {
  display: none !important;
}

@media (max-width: 420px) {
  .topbar {
    align-items: flex-end;
  }

  .corner-tool {
    min-width: 86px;
    padding: 0 12px;
  }
}
