* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f4f6f8;
  color: #17202a;
}

main {
  width: min(1600px, calc(100% - 24px));
  margin: 24px auto;
}

h1 {
  margin: 0 0 20px;
  font-size: 28px;
  line-height: 1.2;
}

.converter {
  display: grid;
  align-items: stretch;
  grid-template-columns: minmax(0, 1fr) 220px minmax(0, 1fr);
  gap: 12px;
}

.panel {
  background: #ffffff;
  border: 1px solid #d7dde3;
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.file-control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

h2 {
  margin: 0;
  font-size: 18px;
}

.editor {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  width: 100%;
  height: 780px;
  overflow: hidden;
  border: 1px solid #c8d0d8;
  border-radius: 6px;
  background: #fbfcfd;
}

.editor.error {
  border-color: #c0392b;
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12);
}

.line-numbers {
  min-width: 44px;
  margin: 0;
  padding: 12px 10px;
  overflow: hidden;
  border-right: 1px solid #d7dde3;
  background: #eef3f8;
  color: #7b8794;
  font: 14px/1.5 Consolas, Monaco, monospace;
  text-align: right;
  user-select: none;
}

.line-number {
  display: block;
  min-height: 21px;
}

.line-number.error {
  border-radius: 4px;
  background: #c0392b;
  color: #ffffff;
  font-weight: 700;
}

textarea {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  overflow: auto;
  border: 0;
  padding: 12px;
  font: 14px/1.5 Consolas, Monaco, monospace;
  color: #17202a;
  background: transparent;
}

textarea:focus,
button:focus,
input:focus {
  outline: 3px solid #99c7ff;
  outline-offset: 2px;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.generate-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

button,
.file-label {
  border: 0;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  background: #1f6feb;
  color: #ffffff;
}

button:hover,
.file-label:hover {
  background: #185abc;
}

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

.file-input:disabled + .file-label {
  cursor: not-allowed;
  opacity: 0.65;
}

button.secondary {
  border: 1px solid #185abc;
  background: #1f6feb;
  color: #ffffff;
}

button.secondary:hover {
  background: #185abc;
}

.generate-button {
  background: #27ae60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  line-height: 1.25;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px 8px 12px;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  white-space: normal;
}

.generate-button::after {
  content: "→";
  flex: 0 0 auto;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.generate-button:hover {
  background: #1e8449;
}

#clear-button {
  border-color: #c77800;
  background: #f39c12;
  width: 100%;
}

#clear-button:hover {
  background: #c77800;
}

input[type="file"] {
  max-width: 240px;
}

.file-name {
  max-width: 220px;
  overflow: hidden;
  color: #566573;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.file-input:focus + .file-label {
  outline: 3px solid #99c7ff;
  outline-offset: 2px;
}

.loader {
  width: 28px;
  height: 28px;
  border: 3px solid #c8d0d8;
  border-top-color: #1f6feb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loader[hidden] {
  display: none;
}

.editor-loader {
  position: absolute;
  top: calc(50% - 14px);
  left: calc(44px + (100% - 44px) / 2 - 14px);
  z-index: 2;
  pointer-events: none;
}

.message {
  min-height: 22px;
  margin-top: 14px;
  text-align: center;
  color: #566573;
}

.message.error {
  color: #c0392b;
}

.message.success {
  color: #1e8449;
}

.notice {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: max-content;
  max-width: min(560px, calc(100% - 32px));
  padding: 18px 18px 18px 20px;
  border: 1px solid #b7dfc6;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(23, 32, 42, 0.18);
  background: #eaf8ef;
  color: #1e8449;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.45;
}

.notice[hidden] {
  display: none;
}

.notice-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #1e8449;
  font-size: 26px;
  line-height: 1;
}

.notice-close:hover {
  background: rgba(30, 132, 73, 0.12);
}

.notice.error {
  border-color: #f0b8b2;
  background: #fdecea;
  color: #c0392b;
}

.notice.error .notice-close {
  color: #c0392b;
}

.notice.error .notice-close:hover {
  background: rgba(192, 57, 43, 0.12);
}

.notice.info {
  border-color: #bad5f5;
  background: #eef6ff;
  color: #185abc;
}

.notice.info .notice-close {
  color: #185abc;
}

.notice.info .notice-close:hover {
  background: rgba(24, 90, 188, 0.12);
}

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

@media (max-width: 800px) {
  main {
    width: min(100% - 16px, 1600px);
    margin: 20px auto;
  }

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

  .actions {
    order: 2;
  }

  .panel:last-of-type {
    order: 3;
  }

  textarea {
    min-height: 0;
  }

  .editor {
    height: 600px;
  }

  .panel-header,
  .file-control {
    align-items: flex-start;
    flex-direction: column;
  }

  .file-name {
    max-width: 100%;
  }
}
