:root {
  color-scheme: dark;
  --bg: #06111f;
  --panel: rgba(10, 25, 44, 0.86);
  --panel-strong: rgba(13, 35, 60, 0.96);
  --cyan: #22d3ee;
  --green: #22c55e;
  --purple: #8b5cf6;
  --text: #e9fbff;
  --muted: #91a7ba;
  --border: rgba(96, 221, 255, 0.22);
  --shadow: rgba(0, 224, 255, 0.18);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 18% 0%, rgba(34, 211, 238, 0.15), transparent 28rem),
    radial-gradient(circle at 92% 16%, rgba(139, 92, 246, 0.18), transparent 24rem),
    linear-gradient(145deg, #030914, var(--bg));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(22px, env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.1;
}

.status-pill {
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 999px;
  color: #b8f8ff;
  background: rgba(4, 18, 32, 0.78);
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.12);
}

.mode-card,
.diagram-card,
.result-card,
.input-card {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.26), inset 0 0 18px rgba(34, 211, 238, 0.04);
  backdrop-filter: blur(14px);
}

.mode-card {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  padding: 8px;
  margin-bottom: 12px;
}

.mode-button {
  min-height: 42px;
  padding: 6px 7px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 14px;
  color: #c8d8e8;
  background: rgba(11, 24, 43, 0.92);
  font-size: 12px;
  font-weight: 800;
}

.mode-button.active {
  border-color: rgba(34, 211, 238, 0.75);
  color: #ffffff;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.95), rgba(139, 92, 246, 0.95));
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.28);
}

.diagram-card {
  height: 150px;
  margin-bottom: 12px;
  padding: 14px;
  overflow: hidden;
}

.lathe-diagram {
  position: relative;
  height: 100%;
  border-radius: 16px;
  background:
    linear-gradient(rgba(34, 211, 238, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.08) 1px, transparent 1px),
    radial-gradient(circle at 35% 50%, rgba(34, 211, 238, 0.24), transparent 10rem),
    #07101d;
  background-size: 18px 18px, 18px 18px, auto, auto;
}

.part {
  position: absolute;
  left: 42px;
  top: 48%;
  width: 56%;
  height: 34px;
  border-radius: 18px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, #d9f99d, #22d3ee 52%, #8b5cf6);
  box-shadow: 0 0 24px rgba(34, 211, 238, 0.35);
}

.tool {
  position: absolute;
  right: 54px;
  bottom: 22px;
  width: 58px;
  height: 46px;
  clip-path: polygon(0 100%, 100% 0, 82% 100%);
  background: linear-gradient(135deg, #facc15, #fb7185);
}

.feed-line {
  position: absolute;
  right: 34px;
  top: 22px;
  bottom: 22px;
  width: 3px;
  border-radius: 99px;
  background: var(--green);
  box-shadow: 0 0 18px rgba(34, 197, 94, 0.55);
}

.result-card {
  min-height: 112px;
  margin-bottom: 12px;
  padding: 14px;
  background: linear-gradient(145deg, rgba(6, 78, 59, 0.5), rgba(10, 25, 44, 0.9));
}

.result-title {
  margin-bottom: 7px;
  color: #a7f3d0;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#resultText {
  margin: 0;
  white-space: pre-wrap;
  color: #ecfeff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.55;
}

.input-card {
  display: grid;
  gap: 11px;
  padding: 14px;
  background: var(--panel-strong);
}

.field {
  display: grid;
  gap: 5px;
}

.field[hidden] {
  display: none;
}

.field span {
  color: #baecff;
  font-size: 12px;
  font-weight: 900;
}

.field input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid rgba(125, 211, 252, 0.28);
  border-radius: 15px;
  outline: none;
  color: #f8fdff;
  background: rgba(2, 10, 20, 0.82);
  font-size: 16px;
}

.field input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12), 0 0 18px rgba(34, 211, 238, 0.16);
}

.field input::placeholder {
  color: rgba(190, 213, 229, 0.48);
}

.primary-button {
  min-height: 52px;
  margin-top: 3px;
  border: 0;
  border-radius: 16px;
  color: white;
  background: linear-gradient(135deg, #06b6d4, #8b5cf6);
  box-shadow: 0 14px 28px rgba(34, 211, 238, 0.2);
  font-size: 16px;
  font-weight: 900;
}

@media (max-width: 380px) {
  .mode-card {
    grid-template-columns: repeat(2, 1fr);
  }

  .diagram-card {
    height: 132px;
  }
}
