#tile_sets {
  flex: 1 1 auto;
  width: 100%;
  overflow: auto;
  background: #f4f7fa;
}

.tile_sets_container,
.tile_set_page,
.tile_set_editor {
  box-sizing: border-box;
  width: min(1100px, calc(100% - 48px));
  margin: 0 auto;
  padding: 32px 0 52px;
  color: #263746;
}

.tile_sets_header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;

  h1 {
    margin: 5px 0 6px;
    color: #263746;
    font-size: clamp(32px, 4vw, 44px);
    font-weight: 400;
    line-height: 1.05;
  }

  p {
    margin: 0;
    color: #647181;
    font-size: 16px;
    line-height: 1.45;
  }
}

.tile_sets_eyebrow {
  color: #238cb9;
  font: 13px 'Acme';
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tile_sets_primary_action,
.tile_set_back,
.tile_set_submit {
  box-sizing: border-box;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid #1686bb;
  border-radius: 8px;
  background: var(--btn-primary);
  color: #102f40;
  cursor: pointer;
  font: 16px 'Acme';
  text-decoration: none;
  box-shadow: 0 2px 5px rgba(25, 48, 68, 0.14);

  &:hover,
  &:focus-visible {
    border-color: #0874aa;
    background: #56c6f7;
    color: #102f40;
  }

  &:focus-visible {
    outline: 2px solid #176b96;
    outline-offset: 2px;
  }
}

.tile_set_back {
  border-color: #aebdca;
  background: #fff;
  color: #34475a;

  &:hover,
  &:focus-visible {
    border-color: #7891a3;
    background: #eef5f8;
    color: #176b96;
  }
}

.tile_values_panel,
.tile_set_card,
.tile_set_breakdown,
.tile_set_form_panel {
  box-sizing: border-box;
  border: 1px solid #d5dee6;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 12px rgba(25, 48, 68, 0.07);
}

.tile_values_panel {
  margin-bottom: 30px;
  padding: 22px;
}

.tile_sets_section_heading,
.tile_items_heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 17px;

  h2 {
    margin: 3px 0 0;
    color: #263746;
    font-size: 25px;
    font-weight: 400;
    line-height: 1.15;
  }

  p {
    max-width: 480px;
    margin: 0;
    color: #647181;
    font-size: 14px;
    line-height: 1.4;
    text-align: right;
  }
}

.tile_value_grid,
.tile_distribution {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
  gap: 6px;
}

.tile_value,
.tile_quantity {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 0;
  height: 52px;
  overflow: hidden;
  border: 1px solid #afbdc8;
  border-radius: 7px;
  background: linear-gradient(180deg, #f8fafb 0%, #e6edf1 100%);
  color: #263746;
  box-shadow: 0 2px 3px rgba(20, 38, 51, 0.11);

  .tile_letter {
    font: 28px/1 'Ubuntu Mono', monospace;
  }
}

.tile_value {
  .tile_points {
    position: absolute;
    right: 4px;
    bottom: 3px;
    color: #526171;
    font: 12px/1 'Yanone Kaffeesatz', sans-serif;
  }
}

.tile_sets_catalog {
  min-width: 0;
}

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

.tile_set_card {
  min-width: 0;
  overflow: hidden;
}

.tile_set_card_header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 17px 19px;
  border-bottom: 1px solid #dce4ea;
  background: linear-gradient(110deg, #f8fbfd 0%, #edf4f7 100%);

  h3 {
    min-width: 0;
    margin: 0;
    font: 22px/1.2 'Acme';

    a {
      color: #263746;

      &:hover,
      &:focus-visible {
        color: #176b96;
      }
    }
  }
}

.tile_set_admin_actions {
  display: flex;
  flex: none;
  gap: 6px;

  a {
    padding: 5px 8px;
    border: 1px solid #b7c4ce;
    border-radius: 6px;
    background: #fff;
    color: #526171;
    font-size: 12px;

    &:hover,
    &:focus-visible {
      border-color: #7f96a6;
      color: #176b96;
    }
  }

  .tile_set_destroy {
    color: #a43343;

    &:hover,
    &:focus-visible {
      border-color: #c97984;
      color: #8e2635;
    }
  }
}

.tile_set_stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  border-bottom: 1px solid #e1e7ec;

  div {
    padding: 13px 15px;
    border-right: 1px solid #e1e7ec;

    &:last-child {
      border-right: 0;
    }
  }

  dt {
    margin-bottom: 4px;
    color: #7a8894;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  dd {
    margin: 0;
    color: #263746;
    font: 20px/1 'Acme';

    small {
      margin-left: 3px;
      color: #647181;
      font: 12px Arial, sans-serif;
    }
  }
}

.tile_distribution {
  grid-template-columns: repeat(auto-fit, minmax(34px, 1fr));
  padding: 15px;

  .tile_quantity {
    height: 43px;
    border-radius: 6px;

    .tile_letter {
      font-size: 22px;
    }

    .tile_amount {
      position: absolute;
      right: 3px;
      bottom: 2px;
      color: #526171;
      font-size: 10px;
      font-weight: 700;
    }
  }
}

.tile_set_page,
.tile_set_editor {
  flex: 1 1 auto;
}

.tile_set_breakdown {
  max-width: 760px;
  overflow: hidden;

  table {
    width: 100%;
    border-collapse: collapse;
  }

  th,
  td {
    padding: 12px 18px;
    border-bottom: 1px solid #e2e8ed;
    color: #526171;
    text-align: left;
  }

  th {
    background: #eef4f7;
    color: #34475a;
    font-size: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  tbody tr:last-child td {
    border-bottom: 0;
  }

  tbody tr:hover {
    background: #f6fafc;
  }

  .breakdown_letter {
    color: #263746;
    font: 20px 'Ubuntu Mono', monospace;
  }
}

.tile_set_form_panel {
  padding: 24px;

  form {
    width: 100%;
  }

  .tile_set_form_basics {
    display: flex;
    align-items: flex-end;
    gap: 24px;
    margin-bottom: 28px;
    padding-bottom: 22px;
    border-bottom: 1px solid #dce4ea;
  }

  .field {
    margin: 0;

    label {
      display: block;
      margin-bottom: 5px;
      color: #526171;
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.04em;
      text-transform: uppercase;
    }

    input[type='text'],
    input[type='number'] {
      box-sizing: border-box;
      width: 100%;
      border: 1px solid #b7c4ce;
      border-radius: 7px;
      background: #fff;
      color: #263746;

      &:focus {
        border-color: #29b6f6;
        outline: 2px solid rgba(41, 182, 246, 0.2);
      }
    }
  }

  .tile_set_form_basics .field:first-child {
    flex: 1 1 320px;
    max-width: 520px;
  }

  .active_field {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;

    label {
      margin: 0;
    }
  }

  .tile_item_forms {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 10px;
  }

  .tsi_form {
    display: grid;
    grid-template-columns: 48px 1fr 1fr;
    align-items: end;
    gap: 8px;
    min-width: 0;
    padding: 11px;
    border: 1px solid #d5dee6;
    border-radius: 9px;
    background: #f8fafb;

    .letter {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 46px;
      height: 46px;
      border: 1px solid #aebdca;
      border-radius: 7px;
      background: linear-gradient(180deg, #fff, #e7edf1);
      color: #263746;
      font: 28px 'Ubuntu Mono', monospace;
      box-shadow: 0 2px 3px rgba(20, 38, 51, 0.1);
    }

    input[type='number'] {
      height: 34px;
      padding: 5px;
      font-size: 14px;
    }
  }

  .actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 22px;
  }
}

@media (max-width: 760px) {
  .tile_sets_container,
  .tile_set_page,
  .tile_set_editor {
    width: calc(100% - 28px);
    padding-block: 24px 38px;
  }

  .tile_sets_header,
  .tile_sets_section_heading,
  .tile_items_heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;

    p {
      text-align: left;
    }
  }

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

  .tile_value_grid {
    grid-template-columns: repeat(auto-fit, minmax(38px, 1fr));
  }

  .tile_set_form_panel {
    padding: 17px;

    .tile_set_form_basics {
      align-items: stretch;
      flex-direction: column;
      gap: 14px;
    }

    .tile_item_forms {
      grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    }
  }
}

@media (max-width: 430px) {
  .tile_values_panel {
    padding: 16px;
  }

  .tile_set_stats {
    grid-template-columns: 1fr;

    div {
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-right: 0;
      border-bottom: 1px solid #e1e7ec;

      &:last-child {
        border-bottom: 0;
      }
    }

    dt {
      margin: 0;
    }
  }
}
