@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #000000;
  --ink: #ffffff;
  --muted: #c8c8c8;
  --line: #2f2f2f;
  --focus-accent: #ffd84d;
  --shadow: 0 20px 56px rgba(0, 0, 0, .36);
  --app-nav-bg: rgba(0, 0, 0, .78);
  --app-nav-border: rgba(255, 255, 255, .28);
  --app-nav-text: var(--ink);
  --app-nav-hover-border: rgba(255, 255, 255, .56);
  --app-nav-hover-text: var(--ink);
  --app-nav-active-bg: #ffffff;
  --app-nav-active-text: #000000;
  --app-nav-active-shadow: 0 12px 28px rgba(255, 255, 255, .14);
  --control-label-column: 150px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button, input, select {
  font: inherit;
}

.focus-page {
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 5vw;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
  background: rgba(0, 0, 0, .88);
  backdrop-filter: blur(18px);
}

#app-title {
  min-width: 0;
  overflow: hidden;
  font-size: 22px;
  font-weight: 900;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  gap: 10px;
  min-width: 0;
}

.language-select {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  background: #000;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  padding: 7px 12px;
}

.language-select option {
  background: #000;
  color: #fff;
}

.setup-view {
  max-width: 1120px;
  margin: 0 auto;
  padding: 36px 24px 72px;
}

.hero-copy {
  max-width: 1100px;
}

h1 {
  max-width: 1040px;
  margin: 0;
  color: var(--ink);
  font-size: clamp(24px, 3.2vw, 32px);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: 0;
  white-space: nowrap;
}

.hero-copy p {
  max-width: 820px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.7;
}

.setup-grid {
  display: block;
  margin-top: 28px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(12, 12, 12, .96);
  box-shadow: var(--shadow);
  min-height: 520px;
  padding: 24px;
}

.panel-heading {
  display: grid;
  grid-template-columns: var(--control-label-column) minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.duration-inline {
  width: 100%;
  margin-bottom: 18px;
}

h2 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0;
}

.shape-selection-label {
  flex: 0 0 auto;
  font-size: 18px;
}

.duration-heading {
  font-size: 18px;
}

.panel p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.chip-button {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
  background: #000;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  padding: 8px 13px;
}

.chip-button:hover {
  border-color: rgba(255, 255, 255, .56);
  color: var(--ink);
}

.svg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 132px);
  gap: 12px;
  justify-content: start;
}

.svg-card {
  display: grid;
  grid-template-rows: 98px auto;
  gap: 10px;
  width: 132px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #0b0b0b;
  color: var(--ink);
  cursor: pointer;
  padding: 12px;
  text-align: center;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.svg-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, .28);
}

.svg-card.is-selected {
  border-color: #ffd84d;
  background: #0b0b0b;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px rgba(255, 216, 77, .5), 0 14px 28px rgba(0, 0, 0, .34);
}

.svg-preview {
  display: grid;
  place-items: center;
  border-radius: 12px;
  padding: 14px;
}

.svg-preview svg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .08));
}

.svg-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.duration-control {
  display: grid;
  grid-template-columns: var(--control-label-column) minmax(0, 420px);
  align-items: center;
  gap: 14px;
  width: 100%;
}

.duration-control input {
  width: 100%;
  accent-color: var(--focus-accent);
}

.duration-control strong {
  color: var(--muted);
  font-size: 14px;
}

.duration-value-text {
  justify-self: start;
}

.empty-message {
  max-width: 420px;
  border: 1px solid rgba(255, 99, 99, .28);
  border-radius: 14px;
  background: rgba(255, 99, 99, .08);
  color: #ffb8c1;
  font-size: 14px;
  font-weight: 800;
  padding: 12px;
}

.start-area {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 12px;
  margin-top: 28px;
}

.start-button {
  min-width: 170px;
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #000;
  cursor: pointer;
  font-size: 15px;
  font-weight: 900;
  padding: 15px 22px;
  box-shadow: 0 18px 38px rgba(255, 255, 255, .12);
}

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

.render-view {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
}

.focus-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #000;
  transition: background-color .28s ease, color .28s ease;
}

.focus-stage svg {
  width: min(82vw, 82vh);
  height: min(82vw, 82vh);
  max-width: 92vw;
  max-height: 92vh;
}

.render-controls {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 110;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 28px);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(16px);
  color: #fff;
  padding: 10px;
  transform: translateX(-50%);
  transition: opacity .28s ease, transform .32s ease;
  will-change: transform;
}

.render-view.controls-hidden .render-controls {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(100% + 34px));
}

.controls-handle {
  position: fixed;
  left: 50%;
  bottom: max(0px, env(safe-area-inset-bottom));
  z-index: 111;
  display: grid;
  place-items: center;
  width: 86px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(14px);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity .24s ease, transform .28s ease;
}

.controls-handle span {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .72);
}

.render-view.controls-hidden .controls-handle {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.controls-handle:focus-visible {
  outline: 2px solid rgba(255, 216, 77, .9);
  outline-offset: 3px;
}

.render-progress {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, .78);
  font-size: 13px;
  font-weight: 900;
  padding-left: 8px;
}

.render-timer {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 48px;
  height: 48px;
}

.render-timer-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.render-timer-bg,
.render-timer-progress {
  fill: none;
  stroke-width: 3;
}

.render-timer-bg {
  stroke: rgba(255, 255, 255, .2);
}

.render-timer-progress {
  stroke: rgba(255, 255, 255, .78);
  stroke-dasharray: 113.097;
  stroke-dashoffset: var(--timer-offset, 113.097);
  stroke-linecap: round;
  transition: stroke-dashoffset .12s linear;
}

.render-timer-text {
  position: relative;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .34);
}

.render-buttons {
  display: flex;
  gap: 8px;
}

.render-buttons button {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  padding: 9px 13px;
}

.render-buttons button:hover {
  background: rgba(255, 255, 255, .24);
}

[hidden] {
  display: none !important;
}

@media (max-width: 640px) {
  .app-header {
    align-items: center;
    flex-direction: row;
    gap: 10px;
  }

  .header-tools {
    align-items: center;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    width: auto;
  }

  .header-tools .app-nav {
    flex: 0 0 auto;
    width: auto;
  }

  .language-select {
    flex: 0 0 auto;
  }

  h1 {
    font-size: clamp(22px, 6vw, 28px);
  }

  .panel-heading {
    flex-direction: column;
  }

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

  .svg-card {
    width: 100%;
  }

  .inline-actions {
    justify-content: flex-start;
  }

  .render-controls {
    align-items: stretch;
    flex-direction: column;
    width: calc(100vw - 28px);
    border-radius: 22px;
  }

  .render-view.controls-hidden .render-controls {
    transform: translate(-50%, calc(100% + 28px));
  }

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