/* Ngăn double-tap zoom trên iOS */
* {
  touch-action: manipulation;
}

body {
  padding: 50px;
  font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
}
h3 {
  margin-block-end: -4px;
}

a {
  color: #deb223;
}
@media only screen and (max-width: 599px) {
  body {
    margin: 4px;
    padding: 4px;
    padding-top: 0;
    padding-left: 8px;
  }
}
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  /* padding: 10px; */
}
/* .container {
  border-radius: 5px;
  background-color: #f2f2f2;
  padding: 20px;
} */
/* textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  resize: vertical;
} */
.textarea, input[type="text"] {
  display: block;
  padding: .625em;
  color: #363636;
  align-items: center;
  border: 1px solid #dbdbdb;
  border-radius: 3px;
  box-shadow: inset 0 1px 2px rgba(10,10,10,.1);
  outline: none;
  font-family: sans-serif;
  padding-top: 0.5em;
}
.textarea, input[type="text"] {
  padding-right: 0px;
}
.textarea {
  max-height: 600px;
  max-width: 100%;
  min-height: 182px;
  width: calc(100% - 20px);
  font-size: 22px;
}
.cham-keyboard table td,
.font-cham {
  font-family: 'Noto Sans Cham';
  font-size: 22px;
}

.cham-keyboard table td {
  font-size: 24px;
  padding: 5px;
  border: 1px solid #abc;
  color: #00269b;
  transition: all 0.05s ease-out;
  max-width: 45px;
  min-width: 25px;
  min-height: 42px;
  text-align: center;
  user-select: none;
  -moz-user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  border-radius: 4px;
  background-color: #f8f8f8;
  box-shadow: 0 2px 0 #999;
  position: relative;
  width: 30px;
}

@media only screen and (max-width: 599px) {
  .cham-keyboard table.cham-keyboard-desktop td {
    min-width: calc((100vw - 85px)/10);
  }
  .cham-keyboard table.cham-keyboard-mobile td {
    min-width: calc((100vw - 45px)/10);
  }

  .cham-keyboard tbody tr.more-key-row td {
    min-width: calc((100vw - 85px)/12.5);
    width: 20px;
  }
}

.cham-keyboard table td .cham-char {
  font-family: 'Noto Sans Cham', Arial, Helvetica, sans-serif;
  font-size: 24px;
  line-height: 1;
  display: block;
  margin-top: 2px;
}

.cham-keyboard table td .latin-label {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 9px;
  color: #666;
  line-height: 1;
  font-weight: normal;
  position: absolute;
  bottom: 2px;
  right: 3px;
}
.cham-keyboard {
  /* display: flex; */
  justify-content: center;
}
.cham-keyboard table {
  width: 100%;
}
.cham-keyboard tbody {
  display: flex;
  flex-wrap: wrap;
  flex-direction: column;
  gap: 9px
}

.cham-keyboard tbody tr {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-content: center;
  justify-content: center;
}
.cham-keyboard tbody tr.more-key-row td {
  padding: 5px 2.7px;
}


@media only screen and (max-width: 599px) {
  .cham-keyboard table td {
    padding: 1px;
  }
  .cham-keyboard tbody tr {
    gap: 5px;
  }
  .cham-keyboard .cham-keyboard-desktop tbody tr {
    gap: 1px;
  }
}
.cham-keyboard table td:hover {
  background-color: #e8e8e8;
}

.cham-keyboard table td:active {
  background-color: #ddd;
  box-shadow: 0 0 0 #999;
  transform: translateY(2px);
}

@media only screen and (min-width: 600px) {
  .flex {
      display: flex;
      justify-content: space-around;
  }
  .flex > div {
      width: 50%;
  }
}
nav ul {
  list-style: none;
  margin: 10px 0;
  padding: 0;
}
@media only screen and (min-width: 600px) {
  nav ul {
      /* display: flex; */
      list-style: none;
      margin: 10px 0;
      padding: 0;
  }
}
nav ul li {
  padding-right: 20px;
  display: inline-block;
  height: 40px;
}
nav ul li a {
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease-out;
  vertical-align: middle;
  border: 2px solid #6b4a3f;
  padding: 0.55em 1em;
  margin: 0.5rem 0;
  background:#805549;
  color: #fff;
  text-decoration: none;
  font-family: sans-serif;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  position: relative;
  display: inline-block;
}
nav ul li a:hover {
  background: #9a6b5f;
  border-color: #8a5a4f;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25);
  transform: translateY(-1px);
}
nav ul li a:active {
  background: #6b4a3f;
  border-color: #5a3d35;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transform: translateY(1px);
}
nav ul li a.active {
  background:  #deb223;
  border-color: #c89a1a;
  box-shadow: 0 2px 4px rgba(200, 154, 26, 0.3);
}
nav ul li a.active:hover {
  background: #f0c850;
  border-color: #deb223;
  box-shadow: 0 3px 6px rgba(200, 154, 26, 0.35);
}
nav ul li a.active:active {
  background: #c89a1a;
  border-color: #b8941a;
  box-shadow: 0 1px 2px rgba(200, 154, 26, 0.2);
  transform: translateY(1px);
}
.back-button {
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease-out;
  vertical-align: middle;
  border: 2px solid #6b4a3f;
  padding: 0.55em 1em;
  margin: 0.5rem 0;
  background:#805549;
  color: #fff;
  text-decoration: none;
  font-family: sans-serif;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  position: relative;
  display: inline-block;
  font-weight: bold;
}
.back-button:hover {
  background: #9a6b5f;
  border-color: #8a5a4f;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25);
  transform: translateY(-1px);
}
.back-button:active {
  background: #6b4a3f;
  border-color: #5a3d35;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transform: translateY(1px);
}
.download-link {
  font-family: sans-serif;
  margin: 7px 0;
  display: inline-block;
}
h1 {
  margin: 22px 0;
  font-family: sans-serif;
}
.hide {
  display: none !important;
}
.cham-word {
  display: inline-block;
  white-space: nowrap;
}
.group {
  display: inline-block;
  white-space: nowrap;
  background-color: rgb(128 85 74 / 15%);
  cursor: pointer;
  border-radius: 2px;
  padding: 0 2px;
  transition: all 0.15s ease-out;
}
.group.focused {
  background-color: rgb(222 178 35 / 40%);
  outline: 2px solid #deb223;
  outline-offset: 1px;
}
.group.changed {
  border-bottom: 2px solid #deb223;
}
#suggestion {
  margin-top: 10px;
  padding: 8px;
  background-color: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: 4px;
  min-height: 30px;
  margin-right: 100px;
}
#suggestion:empty {
  display: none;
}
.hint-item {
  display: inline-block;
  padding: 4px 10px;
  margin: 2px;
  background-color: rgb(128 85 74 / 15%);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease-out;
}
.hint-item:hover {
  background-color: rgb(128 85 74 / 30%);
}
.hint-item.active {
  background-color: #deb223;
  color: #fff;
}
#converted {
  word-wrap: break-word;
  overflow-wrap: break-word;
  margin-top: 10px;
  font-size: 30px;
}
#pop-up-hint {
  display: inline-block;
  color: #222;
  position: absolute;
  z-index: 10;
  border: 1px solid #f8f8f8;
  background-color: rgba(250, 250, 250, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  font-size: 22px;
}
#pop-up-hint .list {
  cursor: pointer;
}
#pop-up-hint .list div {
  background-color: rgba(0, 0, 0, 0.02);
  padding: 1px 5px;
}
#pop-up-hint .list div:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

button {
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease-out;
  vertical-align: middle;
  border: 1px solid transparent;
  border-radius: 0;
  padding: 0.45em 0.35em;
  margin: 0.35rem 0;
  background: #805549;
  color: #fff;
  margin-right: 0;
  border-radius: 6px;
  box-shadow: 0 3px 0 #5a3d35;
  position: relative;
}
button:hover, button:focus {
  background: #deb223;
  color: #fff;
  box-shadow: 0 3px 0 #b8941a;
}
button:active {
  background: #c89a1a;
  box-shadow: 0 0 0 #b8941a;
  transform: translateY(3px);
}
select {
  padding: 0.5rem;
  background-color: #fafafa;
  outline: none;
}
#wrap-cham-keyboard table {
  margin: 0 auto 20px auto;
}
#wrap-cham-keyboard table.cham-keyboard-classical {
  width: 500px;
}

@media only screen and (max-width: 599px) {
  #wrap-cham-keyboard table.cham-keyboard-classical {
    width: calc(100%);
  }
}

label {
  padding: 0 10px;
}
.slider {
  -webkit-appearance: none;
  width: 150px;
  height: 5px;
  border-radius: 5px;   
  background: #d3d3d3;
  outline: none;
  opacity: 0.7;
  -webkit-transition: .2s;
  transition: opacity .2s;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%; 
  background: #805549;
  cursor: pointer;
}

.slider::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #805549;
  cursor: pointer;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.checkbox-label {
  align-items: center;
  cursor: pointer;
  font-size: 14px;
  margin-left: 15px;
}
.checkbox-label input[type="checkbox"] {
  margin-right: 5px;
  cursor: pointer;
}
.button-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
  margin-bottom: 10px;
}
@media only screen and (max-width: 599px) {
  .button-group {
    gap: 3px;
  }
}

.slider {
  width: 70px;
}

/* Nút Clear - màu nhạt hơn và tách xa hơn */
.button-group .clear-btn {
  background: #a08a7f;
  box-shadow: 0 3px 0 #7a6a60;
  margin-left: 12px;
  opacity: 0.85;
}

.button-group .clear-btn:hover,
.button-group .clear-btn:focus {
  background: #b89a8f;
  box-shadow: 0 3px 0 #8a7a70;
  opacity: 1;
}

.button-group .clear-btn:active {
  background: #8a7a70;
  box-shadow: 0 0 0 #7a6a60;
  transform: translateY(3px);
}

/* Mobile Navigation */
.menu-toggle {
  display: none;
}

@media only screen and (max-width: 599px) {
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    /* width: 100%; */
    background: #805549;
    border: none;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 12px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    font-family: sans-serif;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    -webkit-tap-highlight-color: transparent;
  }
  .menu-toggle:hover,
  .menu-toggle:focus {
    background: #9a6b5f;
    outline: none;
  }
  .menu-toggle:active {
    background: #6b4a3f;
  }
  nav ul.nav-menu {
    display: none;
    flex-direction: column;
    background: #f8f8f8;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  }
  nav ul.nav-menu.open {
    display: flex;
  }
  nav ul.nav-menu li {
    display: block;
    margin: 7px 0;
  }
  nav ul.nav-menu li a {
    display: block;
    width: 100%;
    padding: 12px 14px;
    text-align: left;
    box-sizing: border-box;
    border-radius: 6px;
    margin: 2px 0;
  }
}

.options {
  margin-top: 7px;
}
.options input {
  margin-left: 10px;
}

/* Mobile keyboard styles */

/* Mobile mode keyboard layout adjustments */
body.mobile-mode .cham-keyboard table {
  max-width: 600px;
  margin: 0 auto;
}

body.mobile-mode .cham-keyboard td {
  padding: 12px 8px;
  font-size: 24px;
}

body.mobile-mode .latin-label {
  font-size: 11px;
}

/* Layer switch key (ABC/123) - hiển thị như 1 phím bàn phím */
.cham-keyboard table td.layer-switch-key {
  width: 46px;
}
.cham-keyboard table td.layer-switch-key .cham-char {
  font-size: 13px;
  font-weight: bold;
  margin: 0;
}
.cham-keyboard table td.center-key {
  justify-content: center;
  display: flex;
  align-items: center;
}
.cham-keyboard table td.control-key {
  background: #e5e5e5;
}
/* Classical keyboard layout - tất cả hàng cùng độ rộng */
.cham-keyboard-classical tbody tr {
  justify-content: center;
  width: 100%;
}

.cham-keyboard-classical tbody tr td {
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
  width: auto;
}

/* Nút SPACE - rộng gấp đôi các nút khác */
.cham-keyboard table td.space-key {
  min-width: calc(60px + 9px); /* 2 nút (30px x 2) + gap (9px) */
  max-width: calc(90px + 9px);
}

.cham-keyboard table td.space-key-big {
  min-width: calc(90px + 9px);
  max-width: calc(90px + 9px);
}

.cham-keyboard table td.enter-key {
  min-width: calc(32px + 9px); /* 2 nút (30px x 2) + gap (9px) */
}

@media only screen and (max-width: 599px) {
  .cham-keyboard table.cham-keyboard-desktop td.space-key {
    min-width: calc((100vw - 85px)/10 * 2 + 5px); /* 2 nút + 1 gap */
  }
  .cham-keyboard table.cham-keyboard-mobile td.space-key {
    min-width: calc((100vw - 45px)/10 * 2 + 5px);
  }
}