@font-face {
  font-family: 'Geist';
  src: url('fonts/Geist-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Geist';
  src: url('fonts/Geist-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Geist Mono';
  src: url('fonts/GeistMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  --color-bg: #fafaf9;
  --color-text: #171717;
  --color-text-muted: #78716c;
  --color-border: #e7e5e4;
  --color-error: #b91c1c;
  --color-error-bg: #fef2f2;
  --color-success: #16a34a;
  --color-pending: #d6d3d1;

  --color-badge-movies-bg: #e0e7ff;
  --color-badge-movies-text: #3730a3;
  --color-badge-education-bg: #ccfbf1;
  --color-badge-education-text: #115e59;
  --color-badge-general-bg: var(--color-border);
  --color-badge-general-text: #44403c;

  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --space-1: 0.5rem;
  --space-2: 0.75rem;
  --space-3: 1.25rem;
  --space-4: 2rem;
  --space-5: 3.5rem;

  --duration-fast: 150ms;
  --duration-normal: 320ms;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.masthead {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--color-border);
}

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-2) 1.25rem;
}

.masthead__mark {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
}

main {
  flex: 0 0 auto;
  height: var(--main-height, auto);
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

main.main--top {
  flex: 1 1 auto;
  height: auto;
  justify-content: flex-start;
  padding-top: var(--space-5);
}

.parse-form {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.parse-form__input {
  flex: 1 1 280px;
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--color-text);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 0;
}

.parse-form__input:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

.parse-form__button {
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1rem;
  color: #fff;
  background: var(--color-text);
  border: 1px solid var(--color-text);
  border-radius: 0;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out-expo), color var(--duration-fast) var(--ease-out-expo);
}

.parse-form__button:hover:not(:disabled) {
  background: var(--color-bg);
  color: var(--color-text);
}

.parse-form__button:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

.parse-form__button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .parse-form {
    flex-direction: column;
  }

  .parse-form__input {
    flex: 1 1 auto;
  }

  .parse-form__button {
    width: 100%;
  }
}

.progress-bar {
  width: 100%;
  height: 1px;
  margin: var(--space-2) 0 0;
  background: var(--color-text);
  transform-origin: left center;
  animation: progress-sweep 1.4s var(--ease-out-expo) infinite;
}

@keyframes progress-sweep {
  0% { transform: scaleX(0); opacity: 0.3; }
  50% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(0); opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
  .progress-bar {
    animation: none;
    transform: scaleX(1);
    opacity: 0.5;
  }

  .result,
  .error {
    transition: none;
  }

  .health-dot {
    transition: none;
  }
}

.error {
  margin: var(--space-4) 0 0;
  padding: var(--space-2) var(--space-3);
  border-left: 2px solid var(--color-error);
  background: var(--color-error-bg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--duration-normal) var(--ease-out-expo), transform var(--duration-normal) var(--ease-out-expo);
}

.error.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.error__label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-error);
  margin-right: var(--space-1);
}

.error__message {
  font-size: 0.9375rem;
}

.result {
  margin: var(--space-4) 0 0;
  border-radius: 0;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--duration-normal) var(--ease-out-expo), transform var(--duration-normal) var(--ease-out-expo);
}

.result.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.result__meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 0.2em 0.5em;
  border-radius: 0;
}

.badge--movies {
  background: var(--color-badge-movies-bg);
  color: var(--color-badge-movies-text);
}

.badge--education {
  background: var(--color-badge-education-bg);
  color: var(--color-badge-education-text);
}

.badge--general {
  background: var(--color-badge-general-bg);
  color: var(--color-badge-general-text);
}

.result__skipped {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-2);
}

.result__text h3,
.result__text h4,
.result__text h5 {
  font-weight: 600;
  line-height: 1.3;
  margin: 1em 0 0.4em;
}

.result__text p {
  margin: 0 0 0.75em;
}

.result__text ul {
  margin: 0 0 0.75em;
  padding-left: 1.25em;
}

.result__text ol {
  margin: 0 0 0.75em;
  padding-left: 1.25em;
}

.hairline {
  height: 1px;
  background: var(--color-border);
  margin-block: var(--space-2);
}

.result__stats {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin: 0;
}

.copy-btn {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--color-text);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 0;
  padding: 0.35em 0.75em;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out-expo);
}

.copy-btn:hover:not(:disabled) {
  border-color: var(--color-text);
}

.copy-btn:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

.copy-btn:disabled {
  color: var(--color-text-muted);
  cursor: default;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-pending);
  transition: background var(--duration-fast) var(--ease-out-expo);
}

.health-dot--ok {
  background: var(--color-success);
}

.health-dot--down {
  background: var(--color-error);
}

.icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  fill: currentColor;
}

.settings-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  z-index: 20;
  border: 1px solid var(--color-border);
  border-radius: 0;
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out-expo), border-color var(--duration-fast) var(--ease-out-expo);
}

.settings-btn:hover,
.settings-btn:focus-visible {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.settings-panel {
  position: fixed;
  top: 46px;
  right: 12px;
  z-index: 10;
  min-width: 200px;
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: 0;
  background: var(--color-bg);
}

.settings-panel__label {
  display: block;
  margin-bottom: 0.35em;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.settings-panel__select {
  width: 100%;
  padding: 0.35em 0.5em;
  border: 1px solid var(--color-border);
  border-radius: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.user-list {
  list-style: none;
  margin: 0 0 var(--space-1);
  padding: 0;
}

.user-list__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5em;
  padding: 0.3em 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.user-list__name--pending {
  color: var(--color-text-muted);
}

.user-list__delete,
.user-list__confirm-delete,
.user-list__cancel-delete,
.user-list__confirm-add {
  border: 1px solid var(--color-border);
  border-radius: 0;
  background: var(--color-bg);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.15em 0.5em;
  line-height: 1.4;
}

.user-list__confirm-delete {
  color: var(--color-error);
  border-color: var(--color-error);
}

.user-list__input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.2em 0.4em;
}

.user-list__add-btn {
  border: none;
  background: none;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
}

.user-list__add-btn:hover {
  color: var(--color-text);
}

.bottom-panel {
  flex: 1 1 auto;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}

.bottom-panel__tabs {
  flex: 0 0 auto;
  display: flex;
}

.bottom-panel__tab {
  flex: 1 1 0;
  padding: var(--space-2) var(--space-1);
  border: none;
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  background: none;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out-expo);
}

.bottom-panel__tab:last-child {
  border-right: none;
}

.bottom-panel__tab.is-active {
  color: var(--color-text);
  font-weight: 600;
  border-bottom-color: transparent;
}

.bottom-panel__tab:hover,
.bottom-panel__tab:focus-visible {
  color: var(--color-text);
}

.bottom-panel__content {
  flex: 1 1 auto;
  overflow-y: auto;
  box-sizing: border-box;
  padding: var(--space-3);
}

.journal-summary {
  display: flex;
  gap: var(--space-3);
  margin: 0 0 var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

.journal-summary__group {
  flex: 1 1 0;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--color-text-muted);
  white-space: pre-line;
}

.journal-summary__group:empty {
  flex: 0 0 0;
}

.journal-summary__group + .journal-summary__group:not(:empty) {
  padding-left: var(--space-3);
}

.journal-panel__empty {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.journal-table-wrap {
  overflow-x: auto;
}

.journal-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  white-space: nowrap;
}

.journal-table th,
.journal-table td {
  padding: 0.35em 0.6em;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.journal-table th {
  position: sticky;
  top: 0;
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-weight: 400;
}

.journal-table td--cost {
  color: var(--color-text-muted);
}

.ig-account-list {
  list-style: none;
  margin: 0 0 var(--space-1);
  padding: 0;
}

.ig-account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0.3em 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.ig-account-row__status--active {
  color: var(--color-success);
}

.ig-account-row__status--disabled {
  color: var(--color-error);
}
