@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/IBMPlexSans-VariableFont_wdth,wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/IBMPlexMono-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ============================================================
   RESET
   ============================================================ */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

/* ============================================================
   BASE
   ============================================================ */

body {
  background: #f5f5f5;
  color: #202124;
  font-family: "IBM Plex Sans", sans-serif;
}

button,
select,
input {
  font-family: inherit;
}

[hidden] {
  display: none !important;
}

/* ============================================================
   CONTAINER
   ============================================================ */

.container {
  width: min(1000px, 100%);
  margin: 0 auto;
  padding: 30px 20px 50px;
}

h1 {
  margin: 0 0 30px;
  font-size: 32px;
  font-weight: 600;
}

/* ============================================================
   TRAINING
   ============================================================ */

.training {
  padding: 25px;
  background: #fff;
  border: 1px solid #d8d8d8;
  border-radius: 10px;
}

/* ============================================================
   CONTROLS
   ============================================================ */

.control-group {
  margin-bottom: 18px;
}

.control-group > label {
  display: block;
  margin-bottom: 7px;
  color: #555;
  font-size: 14px;
  font-weight: 500;
}

select,
input[type="number"] {
  width: 100%;
  height: 42px;
  padding: 8px 12px;
  background: #fff;
  color: #202124;
  border: 1px solid #bdbdbd;
  border-radius: 5px;
  font-size: 16px;
}

select:focus,
input[type="number"]:focus {
  outline: none;
  border-color: #777;
}

input[type="range"] {
  width: 100%;
}

/* ============================================================
   MODE SWITCH
   ============================================================ */

.mode-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 28px;
  margin-bottom: 18px;
}

.mode-label {
  height: 28px;
  color: #555;
  font-size: 14px;
  font-weight: 500;
  line-height: 28px;
}

.mode-toggle {
  position: relative;
  display: block;
  width: 52px;
  height: 28px;
  flex: 0 0 52px;
  cursor: pointer;
}

.mode-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  opacity: 0;
}

.mode-slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border: 1px solid #999;
  border-radius: 14px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.mode-slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgb(0 0 0 / 25%);
  transition: transform 0.2s ease;
}

.mode-toggle input:checked + .mode-slider {
  background: #777;
}

.mode-toggle input:checked + .mode-slider::before {
  transform: translateX(24px);
}

.mode-toggle input:focus-visible + .mode-slider {
  outline: 2px solid #777;
  outline-offset: 2px;
}

/* ============================================================
   CUSTOM CSV
   ============================================================ */

.custom-csv {
  width: 100%;
  margin: 20px 0;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 17px;
  background: #eee;
  color: #202124;
  border: 1px solid #bdbdbd;
  border-radius: 5px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.file-button:hover {
  background: #e2e2e2;
}

.file-button:active {
  background: #d8d8d8;
}

.custom-files {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.custom-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 5px 6px 5px 12px;
  background: #fff;
  border: 1px solid #d8d8d8;
  border-radius: 5px;
}

.custom-file span {
  min-width: 0;
  overflow: hidden;
  color: #202124;
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-file button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 13px;
  background: #f0d8d8;
  color: #202124;
  border: 1px solid #d2aaaa;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.custom-file button:hover {
  background: #e7caca;
}

/* ============================================================
   CHARACTERS
   ============================================================ */

.characters {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 80px;
  margin: 25px 0;
  padding: 20px;
  background: #fff;
  border: 1px solid #d8d8d8;
  border-radius: 6px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 2px;
  line-height: 1.8;
  overflow-wrap: break-word;
}

/* ============================================================
   SETTINGS
   ============================================================ */

.settings {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 15px;
  margin-top: 25px;
}

.settings .control-group {
  margin-bottom: 0;
}

/* ============================================================
   CWTYPE
   ============================================================ */

.cwtype {
  width: 100%;
}

.cwtype-shortcuts {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  width: 100%;
  margin: 30px 0 18px;
  color: #555;
  font-size: 14px;
  line-height: 24px;
  text-align: center;
  white-space: nowrap;
}

.cwtype-shortcuts span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cwtype-shortcuts kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 24px;
  margin: 0 4px;
  padding: 2px 7px;
  background: #eee;
  color: #202124;
  border: 1px solid #bdbdbd;
  border-radius: 4px;
  box-shadow: 0 1px 0 #d0d0d0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

/* ============================================================
   CWTYPE TRACK
   ============================================================ */

#cwtype-laufband {
  position: relative;
  width: 100%;
  height: 80px;
  margin-bottom: 25px;
  background: #d0d0d0;
  border: 1px solid #aaa;
  border-radius: 6px;
  overflow: hidden;
}

#cwtype-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  z-index: 20;
  width: 2px;
  margin-left: -1px;
  background: #d00000;
  pointer-events: none;
}

#cwtype-track {
  position: absolute;
  top: 50%;
  left: 0;
  display: block;
  width: max-content;
  margin: 0;
  padding: 0;
  color: #202124;
  font-family: "IBM Plex Mono", monospace;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 2px;
  line-height: 1;
  white-space: nowrap;
  transform: translate3d(0, -50%, 0);
  will-change: transform;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 30px;
}

button {
  min-height: 44px;
  padding: 10px 15px;
  background: #eee;
  color: #202124;
  border: 1px solid #bdbdbd;
  border-radius: 5px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: #e2e2e2;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#start,
#cwtype-start {
  background: #d9f0dc;
  border-color: #a9cfae;
}

#pause,
#cwtype-pause {
  background: #f1ebc9;
  border-color: #d4c98c;
}

#stop,
#cwtype-stop {
  background: #f0d8d8;
  border-color: #d2aaaa;
}

/* ============================================================
   STATUS
   ============================================================ */

.status {
  margin-top: 30px;
  padding: 20px;
  background: #fff;
  border: 1px solid #d8d8d8;
  border-radius: 7px;
  text-align: center;
}

.status-text {
  margin-bottom: 15px;
  font-size: 18px;
  font-weight: 500;
}

/* ============================================================
   PROGRESS
   ============================================================ */

.progress {
  width: 100%;
  height: 12px;
  background: #ddd;
  border-radius: 6px;
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: #777;
  transition: width 0.1s linear;
}

.counter {
  margin-top: 10px;
  color: #666;
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
}

/* ============================================================
   SOLUTION
   ============================================================ */

.solution-section {
  margin-top: 30px;
}

#show-solution {
  width: 100%;
}

.solution {
  margin-top: 15px;
  padding: 20px;
  background: #fff;
  border: 1px solid #d8d8d8;
  border-radius: 6px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* ============================================================
   TABLET
   ============================================================ */

@media (max-width: 800px) {
  .settings {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cwtype-shortcuts {
    gap: 22px;
  }
}

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 600px) {
  .container {
    padding: 15px 10px 30px;
  }

  .training {
    padding: 15px;
  }

  .settings {
    grid-template-columns: 1fr;
  }

  .characters {
    font-size: 22px;
  }

  #cwtype-track {
    font-size: 20px;
  }

  .cwtype-shortcuts {
    gap: 12px;
    font-size: 12px;
  }
}

/* ============================================================
   SMALL MOBILE
   ============================================================ */

@media (max-width: 420px) {
  .buttons {
    gap: 6px;
  }

  .buttons button {
    padding: 8px 5px;
    font-size: 14px;
  }

  .mode-switch {
    gap: 10px;
  }

  .cwtype-shortcuts {
    gap: 6px;
    font-size: 11px;
  }

  .cwtype-shortcuts kbd {
    min-width: 28px;
    margin: 0 2px;
    padding: 5px;
  }
}
