* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Roboto, sans-serif;
  background-color: #F9F5FF;
  color: #1C1B1F;
}

a {
  color: #6750A4;
}

a:hover {
  color: #4F378B;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background-color: #6750A4;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.app-bar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
  padding: 0 24px;
  margin: 0 auto;
  max-width: 1200px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-btn {
  --md-text-button-label-text-color: #FFFFFF;
  --md-text-button-hover-label-text-color: #FFFFFF;
  --md-text-button-focus-label-text-color: #FFFFFF;
  --md-text-button-pressed-label-text-color: #FFFFFF;
  --md-text-button-container-shape: 20px;
}

md-filled-button,
md-outlined-button,
md-text-button {
  --md-icon-font-icon-size: 18px;
}

md-filled-button .material-icons,
md-outlined-button .material-icons,
md-text-button .material-icons {
  font-size: 18px;
  vertical-align: middle;
  margin-right: 4px;
}

.menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  color: #FFFFFF;
}

.menu-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.menu-btn .material-icons {
  font-size: 24px;
}

.mobile-menu {
  display: none;
  position: absolute;
  top: 64px;
  right: 16px;
  background: #F3EDF7;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  padding: 8px;
  z-index: 99;
}

.mobile-menu.show {
  display: flex;
  flex-direction: column;
}

.mobile-menu-btn {
  --md-text-button-label-text-color: #1C1B1F;
  justify-content: flex-start;
}

.app-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 500;
  color: #FFFFFF;
  font-family: Roboto, sans-serif;
  letter-spacing: 0.007em;
}

.github-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #FFFFFF;
  transition: background-color 0.2s;
}

.github-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #323232;
  color: #FFFFFF;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 1000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.page {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.mode-row {
  display: flex;
  gap: 24px;
  align-items: center;
}

.mode-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.mode-row span {
  font-family: Roboto, sans-serif;
  font-size: 16px;
  color: #333;
}

.text-wrapper {
  display: flex;
  flex-direction: row;
  width: 100%;
  background-color: #FFF8F5;
  border: 1px solid #E7E0EC;
  border-radius: 16px;
  overflow: hidden;
  min-height: 420px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.panel {
  flex: 1;
  padding: 16px;
  display: flex;
}

.panel>md-filled-text-field {
  flex: 1;
  width: 100%;
}

.divider {
  width: 1px;
  background: #e0e0e0;
  align-self: stretch;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.options {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: #F3EDF7;
  border-radius: 12px;
}

.option {
  display: flex;
  align-items: center;
  gap: 8px;
}

.option-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.option-label {
  font-size: 14px;
  color: #49454F;
  white-space: nowrap;
}

.option-select {
  padding: 8px 12px;
  border: 1px solid #E7E0EC;
  border-radius: 8px;
  background: #FFF8F5;
  font-size: 14px;
  color: #1C1B1F;
  cursor: pointer;
}

.option-select:focus {
  outline: 2px solid #6750A4;
  outline-offset: 2px;
}

.option-input {
  padding: 6px 10px;
  border: 1px solid #E7E0EC;
  border-radius: 6px;
  background: #FFF8F5;
  font-size: 14px;
  width: 60px;
}

.option-input:focus {
  outline: 2px solid #6750A4;
  outline-offset: 2px;
}

.custom-suffix-options {
  margin-top: 8px;
  padding: 12px;
  background: rgba(103, 80, 164, 0.05);
  border-radius: 8px;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
  animation: modal-fade-in 0.3s ease;
}

.modal.hiding {
  display: flex;
  animation: modal-fade-out 0.25s ease forwards;
}

@keyframes modal-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes modal-fade-out {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.modal-panel {
  position: relative;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  background: #F3EDF7;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid #E7E0EC;
  background: #F3EDF7;
}

.modal-header span {
  font-size: 1.25rem;
  font-weight: 500;
  color: #1C1B1F;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #49454F;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close .material-icons {
  font-size: 20px;
}

.modal-close:hover {
  background: #E7E0EC;
}

.modal-content {
  flex: 1;
  padding: 16px 24px;
  overflow-y: auto;
  color: #1C1B1F;
  background: #F3EDF7;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid #E7E0EC;
  background: #F3EDF7;
}

.history-item {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  background: #FFF8F5;
}

.history-timestamp {
  font-size: 0.85rem;
  color: #49454F;
  margin-bottom: 8px;
}

.history-text {
  font-size: 0.9rem;
}

.history-row {
  margin-bottom: 4px;
}

.history-label {
  font-weight: 500;
  color: #49454F;
}

.history-input {
  color: #6750A4;
  word-break: break-all;
}

.history-output {
  color: #07d;
  word-break: break-all;
}

.library-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.library-table th,
.library-table td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid #E7E0EC;
  vertical-align: top;
}

.library-table th {
  background: #F9F5FF;
  font-weight: 500;
  position: sticky;
  top: 0;
  z-index: 1;
}

.library-table td:first-child {
  width: 50px;
  text-align: center;
  font-size: 1.1rem;
}

.library-variants {
  word-break: break-all;
  font-family: monospace;
}

.library-total {
  text-align: center;
  color: #49454F;
  font-size: 0.9rem;
  margin-top: 16px;
}

.lang-modal-panel {
  max-width: 360px;
}

.lang-option {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 12px 16px;
  cursor: pointer;
  border-radius: 8px;
  transition: background-color 0.15s;
  margin-bottom: 4px;
  border: none;
  background: transparent;
  text-align: left;
  font-family: inherit;
  font-size: inherit;
}

.lang-option:focus {
  outline: 2px solid #6750A4;
  outline-offset: 2px;
}

.lang-option:hover {
  background: rgba(103, 80, 164, 0.08);
}

.lang-option.active {
  background: rgba(103, 80, 164, 0.12);
}

.lang-native {
  font-size: 1rem;
  font-weight: 500;
  color: #1C1B1F;
  flex: 1;
}

.lang-name {
  font-size: 0.85rem;
  color: #49454F;
  margin-left: 8px;
}

.lang-check {
  color: #6750A4;
  font-size: 20px;
}

@media (max-width: 768px) {
  .topbar-actions {
    display: none;
  }

  .menu-btn {
    display: flex;
  }

  .app-bar-content {
    padding: 0 16px;
  }

  .app-title {
    font-size: 1rem;
  }
}

@media (max-width: 900px) {
  .text-wrapper {
    flex-direction: column;
  }

  .divider {
    width: 100%;
    height: 1px;
  }
}

@media (prefers-color-scheme: dark) {
  body {
    background-color: #1C1B1F;
    color: #E6E0E9;
  }

  a {
    color: #D0BCFF;
  }

  a:hover {
    color: #E8DEF8;
  }

  .topbar {
    background-color: #4A4458;
  }

  .mobile-menu {
    background: #2B2733;
  }

  .mobile-menu-btn {
    --md-text-button-label-text-color: #E6E0E9;
  }

  .text-wrapper {
    background-color: #1C1B1F;
    border: 1px solid #49454F;
  }

  .divider {
    background: #49454F;
  }

  .options {
    background: #2B2733;
  }

  .option-label {
    color: #CAC4D0;
  }

  .option-select,
  .option-input {
    background: #1C1B1F;
    border-color: #49454F;
    color: #E6E0E9;
  }

  .custom-suffix-options {
    background: rgba(103, 80, 164, 0.1);
  }

  .modal-panel {
    background: #2B2733;
  }

  .modal-header {
    background: #2B2733;
    border-color: #49454F;
  }

  .modal-header span {
    color: #E6E0E9;
  }

  .modal-close {
    color: #938F99;
  }

  .modal-close:hover {
    background: #49454F;
  }

  .modal-content {
    background: #2B2733;
    color: #E6E0E9;
  }

  .modal-actions {
    background: #2B2733;
    border-color: #49454F;
  }

  .history-item {
    background: #1C1B1F;
  }

  .history-timestamp {
    color: #938F99;
  }

  .history-label {
    color: #938F99;
  }

  .history-input {
    color: #D0BCFF;
  }

  .history-output {
    color: #07d;
  }

  .library-table th {
    background: #1C1B1F;
  }

  .library-table th,
  .library-table td {
    border-color: #49454F;
  }

  .library-total {
    color: #938F99;
  }

  md-filled-text-field {
    --md-filled-text-field-container-color: #1C1B1F;
    --md-filled-text-field-label-text-color: #CAC4D0;
    --md-filled-text-field-input-text-color: #E6E0E9;
    --md-filled-text-field-supporting-text-color: #CAC4D0;
    --md-filled-text-field-focus-label-text-color: #D0BCFF;
    --md-filled-text-field-hover-label-text-color: #D0BCFF;
    --md-filled-text-field-active-indicator-color: #D0BCFF;
    --md-filled-text-field-focus-active-indicator-color: #D0BCFF;
    --md-filled-text-field-outline-color: #49454F;
    --md-filled-text-field-hover-outline-color: #938F99;
    --md-filled-text-field-focus-outline-color: #D0BCFF;
    --md-filled-text-field-outline-width: 2px;
  }

  md-switch {
    --md-switch-selected-thumb-color: #D0BCFF;
    --md-switch-selected-track-color: #6750A4;
    --md-switch-unselected-thumb-color: #49454F;
    --md-switch-unselected-track-color: #49454F;
    --md-switch-selected-hover-thumb-color: #EADDFF;
    --md-switch-selected-hover-track-color: #7F67BA;
    --md-switch-unselected-hover-thumb-color: #605C66;
    --md-switch-unselected-hover-track-color: #605C66;
  }

  .lang-option:hover {
    background: rgba(208, 188, 255, 0.08);
  }

  .lang-option:focus {
    outline-color: #D0BCFF;
  }

  .lang-option.active {
    background: rgba(208, 188, 255, 0.12);
  }

  .lang-native {
    color: #E6E0E9;
  }

  .lang-name {
    color: #938F99;
  }

  .lang-check {
    color: #D0BCFF;
  }
}