:root {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --muted2: #9ca3af;
  --border: rgba(0, 0, 0, 0.06);
  --card: #ffffff;
  --accent: #ea580c;
  --accentHover: #c2410c;
  --good: #22c55e;
  --warn: #eab308;
  --bad: #ef4444;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.logo__icon {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.logo__text {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.main {
  min-height: calc(100vh - 132px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.view {
  width: 100%;
  max-width: 420px;
  animation: fadeIn 0.35s ease-out;
}

.view--result {
  text-align: center;
}

.title {
  margin: 0 0 8px;
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.6px;
}

.subtitle {
  margin: 0 0 28px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.04);
}

.row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.input {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  font-size: 16px;
  font-weight: 600;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  background: #fafafa;
  color: var(--fg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.12);
}

input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.55;
  cursor: pointer;
}

.error {
  margin: 0 0 12px;
  text-align: center;
  color: #dc2626;
  font-size: 13px;
  font-weight: 600;
}

.button {
  width: 100%;
  min-height: 48px;
  padding: 14px 20px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.button:hover:not(:disabled) {
  background: var(--accentHover);
}

.button:active:not(:disabled) {
  transform: scale(0.99);
}

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

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: rgba(255, 255, 255, 1);
  animation: spin 0.7s linear infinite;
}

.resultLabel {
  margin: 0 0 16px;
  text-align: center;
  color: var(--muted2);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.flaps {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  margin-bottom: 18px;
}

.flaps__digits {
  display: inline-flex;
  gap: 6px;
  grid-column: 2;
  justify-self: center;
}

.flaps__unit {
  color: var(--muted2);
  font-weight: 700;
  grid-column: 3;
  justify-self: start;
  margin-left: 10px;
}

.flap {
  width: 72px;
  height: 100px;
  border-radius: 10px;
  overflow: hidden;
  background: #1a1a1a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.1);
  position: relative;
}

.flap__inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform;
}

.flap__text {
  font-size: 56px;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.flap__line {
  position: absolute;
  top: 50%;
  left: 4px;
  right: 4px;
  height: 2px;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.4);
}

.flap.is-flipping .flap__inner {
  animation: flip 120ms ease-in-out;
}

.condition {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f3f4f6;
  padding: 8px 16px;
  border-radius: 999px;
  margin: 0 auto 22px;
}

.condition__dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted2);
}

.condition__text {
  font-size: 13px;
  font-weight: 700;
  color: #4b5563;
}

.card--details {
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 14px;
}

.detail {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 0;
  gap: 12px;
}

.detail__k {
  color: var(--muted2);
  font-size: 14px;
  font-weight: 700;
}

.detail__v {
  color: var(--fg);
  font-size: 14px;
  font-weight: 800;
  text-align: right;
  word-break: break-word;
}

.divider {
  height: 1px;
  background: #f3f4f6;
}

.reset {
  width: 100%;
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}

.reset:hover {
  text-decoration: underline;
}

.footer {
  padding: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--muted2);
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes flip {
  0% {
    transform: rotateX(0deg);
  }
  50% {
    transform: rotateX(-35deg);
  }
  100% {
    transform: rotateX(0deg);
  }
}

@media (max-width: 420px) {
  .row {
    grid-template-columns: 1fr;
  }
  .flap {
    width: 62px;
    height: 92px;
  }
  .flap__text {
    font-size: 52px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
