/* 팜시크릿 — 약사들의 수다 (글쓰기)
 * 일반 폼 페이지 — 가운데 정렬 단일 컬럼
 */

  /* ═════════════════════════════════════════════
     메인 카드 상단 — "새 글 작성" 섹션 헤더
     ═════════════════════════════════════════════ */
  .tw-main-head {
    padding-bottom: 22px;
    margin-bottom: 24px;
    border-bottom: 1px solid #f1f3f5;
  }
  .tw-main-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    color: #111827;
    letter-spacing: -0.025em;
    line-height: 1.2;
  }
  .tw-main-desc {
    margin-top: 6px;
    font-size: 14px;
    line-height: 1.55;
    color: #6b7280;
    letter-spacing: -0.005em;
  }
  @media (max-width: 767px) {
    .tw-main-head { padding: 0 0 18px; margin-bottom: 20px; }
    .tw-main-title { font-size: 19px; }
    .tw-main-desc { font-size: 13px; }
  }

  /* 모바일: 좌측 사이드바 숨김 (글쓰기 페이지 한정 — talk-write.css는 이 페이지에서만 로드) */
  @media (max-width: 1023px) {
    .tk-layout > .tk-aside { display: none; }
  }

  /* ═════════════════════════════════════════════
     2단 레이아웃 안의 메인 카드 (view와 동일 톤)
     ═════════════════════════════════════════════ */
  .tw-main {
    background: #fff;
    border: 1px solid #eef0f3;
    border-radius: 14px;
    padding: 32px 36px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  }
  @media (max-width: 1023px) {
    .tw-main { padding: 24px 20px; }
  }
  @media (max-width: 767px) {
    .tw-main {padding: 0;border-radius: 0;border: 0;}
  }
  
  .tw-form {
    display: flex;
    flex-direction: column;
    gap: 28px;
  }
  
  .tw-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .tw-field-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.01em;
  }
  .tw-field-sub {
    margin-left: 6px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    color: #9ca3af;
    letter-spacing: -0.005em;
  }
  .tw-req { color: var(--color-brand); font-size: 13px; }
  
  /* 도움말 메시지 */
  .tw-help {
    display: inline-flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 6px;
    font-size: 14px;
    color: #6b7280;
    letter-spacing: -0.005em;
  }
  .tw-help svg { flex-shrink: 0; margin-top: 1px; color: #9ca3af; }

  /* ═════════════════════════════════════════════
     카테고리 라디오 칩 (이모지 + 타이틀)
     항목 수에 맞춰 자동 분배: 1줄에 최대한, 부족하면 줄바꿈
     ═════════════════════════════════════════════ */
  .tw-radio-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
  }
  @media (max-width: 480px) {
    .tw-radio-row { grid-template-columns: 1fr 1fr; }
  }
  .tw-radio-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
    min-width: 0;
  }
  .tw-radio-chip:hover {
    background: #fafbfc;
    border-color: #d1d5db;
  }
  .tw-radio-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }
  .tw-radio-chip:has(input:checked) {
    border-color: var(--color-brand);
    background: rgba(254, 105, 27, 0.05);
  }
  .tw-radio-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #f3f4f6;
    border-radius: 10px;
    font-size: 18px;
    flex-shrink: 0;
  }
  .tw-radio-chip:has(input:checked) .tw-radio-emoji {
    background: rgba(254, 105, 27, 0.12);
  }
  .tw-radio-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  .tw-radio-text strong {
    font-size: 15px;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ═════════════════════════════════════════════
     인풋 (제목/셀렉트)
     ═════════════════════════════════════════════ */
  .tw-input-wrap {
    position: relative;
  }
  .tw-input {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 15px;
    color: #111827;
    outline: none;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
  }
  .tw-input::placeholder { color: #9ca3af; }
  .tw-input:focus,
  .tw-input:focus-visible {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 4px rgba(254, 105, 27, 0.14);
  }
  select.tw-input {
    appearance: none;
    padding-right: 40px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    cursor: pointer;
  }
  
  #tw-title { padding-right: 64px; height: 54px; font-size: 16px; font-weight: 600; }
  .tw-input-count {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: 11px;
    color: #9ca3af;
    pointer-events: none;
  }

  /* 지역: 시/도 + 구·군 2단 */
  .tw-region-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .tw-region-row select:disabled {
    background-color: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
  }
  @media (max-width: 480px) {
    .tw-region-row { grid-template-columns: 1fr; }
  }
  
  /* ═════════════════════════════════════════════
     리치 에디터
     ═════════════════════════════════════════════ */
  .tw-editor-wrap {
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
  }
  .tw-editor-wrap:focus-within {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 4px rgba(254, 105, 27, 0.14);
  }
  
  .tw-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    padding: 8px 10px;
    background: #fafbfc;
    border-bottom: 1px solid #eef0f3;
  }
  .tw-tb-group {
    display: inline-flex;
    align-items: center;
    gap: 2px;
  }
  .tw-tb-sep {
    width: 1px; height: 18px;
    background: #e5e7eb;
    margin: 0 4px;
  }
  .tw-tb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: #4b5563;
    font-family: var(--font-display);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.1s ease, color 0.1s ease;
  }
  .tw-tb-btn:hover { background: #eef0f3; color: #111827; }
  .tw-tb-btn.is-on {
    background: rgba(254, 105, 27, 0.14);
    color: var(--color-brand-dark);
  }
  
  .tw-editor {
    min-height: 320px;
    max-height: 720px;
    overflow-y: auto;
    padding: 18px 18px 24px;
    font-size: 15.5px;
    line-height: 1.75;
    color: #1f2937;
    outline: none;
    word-break: keep-all;
  }
  .tw-editor.is-empty::before {
    content: attr(data-placeholder);
    display: block;
    white-space: pre-wrap;
    color: #9ca3af;
    pointer-events: none;
  }
  .tw-editor > * + * { margin-top: 12px; }
  .tw-editor h2 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 800;
    color: #111827;
    letter-spacing: -0.02em;
    margin-top: 22px;
  }
  .tw-editor blockquote {
    padding: 12px 16px;
    border-left: 3px solid var(--color-brand);
    background: rgba(254, 105, 27, 0.06);
    border-radius: 0 8px 8px 0;
    color: #5a2008;
    font-weight: 500;
  }
  .tw-editor ul, .tw-editor ol {
    padding-left: 22px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .tw-editor ul { list-style: disc; }
  .tw-editor ol { list-style: decimal; }
  .tw-editor li::marker { color: var(--color-brand); }
  .tw-editor a {
    color: var(--color-brand-dark);
    text-decoration: underline;
    text-underline-offset: 2px;
  }
  .tw-editor img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 4px 0;
  }
  
  /* ═════════════════════════════════════════════
     태그 입력
     ═════════════════════════════════════════════ */
  .tw-tag-input {
    min-height: 48px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    cursor: text;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
  }
  .tw-tag-input:focus-within {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 4px rgba(254, 105, 27, 0.14);
  }
  .tw-tag-list {
    display: contents;
    list-style: none;
    padding: 0;
    margin: 0;
  }
  .tw-tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 0 6px 0 11px;
    background: rgba(254, 105, 27, 0.10);
    color: var(--color-brand-dark);
    border-radius: 9999px;
    font-size: 12.5px;
    font-weight: 600;
  }
  .tw-tag-pill button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; height: 18px;
    background: transparent;
    border: 0;
    border-radius: 9999px;
    color: var(--color-brand-dark);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.1s ease, background 0.1s ease;
  }
  .tw-tag-pill button:hover { opacity: 1; background: rgba(254, 105, 27, 0.2); }
  #tw-tag-input {
    flex: 1;
    min-width: 120px;
    height: 28px;
    border: 0;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: #111827;
  }
  #tw-tag-input::placeholder { color: #9ca3af; }
  
  .tw-tag-suggest {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 2px 0;
  }
  .tw-tag-suggest-label {
    font-family: var(--font-label);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    color: #9ca3af;
    text-transform: uppercase;
    margin-right: 4px;
  }
  .tw-tag-sug {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 10px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 9999px;
    font-size: 14px;
    color: #4b5563;
    cursor: pointer;
    transition: background 0.1s ease, color 0.1s ease, border-color 0.1s ease;
  }
  .tw-tag-sug:hover {
    background: var(--color-brand);
    border-color: var(--color-brand);
    color: #fff;
  }
  .tw-tag-sug.is-used {
    background: #f3f4f6;
    border-color: #f3f4f6;
    color: #9ca3af;
    text-decoration: line-through;
    pointer-events: none;
  }
  
  /* ═════════════════════════════════════════════
     하단 액션 바
     ═════════════════════════════════════════════ */
  .tw-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid #f1f3f5;
    margin-top: 4px;
  }
  .tw-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    padding: 0 22px;
    border: 1.5px solid transparent;
    border-radius: 9999px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    letter-spacing: -0.01em;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
    background: #fff;
  }
  .tw-btn--ghost {
    background: transparent;
    color: #6b7280;
    border-color: transparent;
  }
  .tw-btn--ghost:hover { color: #111827; background: #f3f4f6; }
  .tw-btn--outline {
    color: #374151;
    border-color: #e5e7eb;
  }
  .tw-btn--outline:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #111827;
  }
  .tw-btn--primary {
    background: var(--color-brand);
    color: #fff;
    border-color: var(--color-brand);
    padding: 0 26px;
  }
  .tw-btn--primary:hover {
    background: var(--color-brand-dark);
    border-color: var(--color-brand-dark);
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(254, 105, 27, 0.28);
  }
  @media (max-width: 767px) {
    .tw-actions { gap: 6px; }
    .tw-btn { padding: 0 16px; font-size: 13px; }
    .tw-btn--primary { padding: 0 20px; }
  }
  
  /* 토스트 */
  .tw-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    padding: 12px 22px;
    background: rgba(17, 24, 39, 0.94);
    color: #fff;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    z-index: 90;
    opacity: 0;
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
  }
  .tw-toast.is-on {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  /* ═════════════════════════════════════════════
     모바일 최적화 (≤ 640px / ≤ 480px)
     ═════════════════════════════════════════════ */
  @media (max-width: 767px) {
    /* 폼 — 필드 간 간격 축소 */
    .tw-form { gap: 22px; }

    /* 라벨/도움말 */
    .tw-field-label { font-size: 15px; }
    .tw-field-sub { font-size: 12px; margin-left: 4px; }
    .tw-help { font-size: 12.5px; }

    /* 카테고리 라디오 칩 */
    .tw-radio-chip { padding: 10px 12px; gap: 8px; }
    .tw-radio-emoji { width: 32px; height: 32px; font-size: 16px; }
    .tw-radio-text strong { font-size: 14px; }

    /* 인풋 */
    .tw-input { height: 44px; font-size: 14.5px; padding: 0 14px; }
    #tw-title { height: 50px; font-size: 15.5px; padding-right: 58px; }
    .tw-input-count { font-size: 10.5px; right: 12px; }
    select.tw-input { padding-right: 36px; background-position: right 12px center; }

    /* 리치 에디터 */
    .tw-editor-toolbar { padding: 6px 8px; gap: 2px; }
    .tw-tb-sep { margin: 0 2px; }
    .tw-tb-btn { width: 28px; height: 28px; font-size: 13px; }
    .tw-editor {
      min-height: 220px;
      max-height: 60vh;
      padding: 14px 14px 18px;
      font-size: 14.5px;
      line-height: 1.7;
    }
    .tw-editor h2 { font-size: 16px; margin-top: 18px; }
    .tw-editor blockquote { padding: 10px 14px; }

    /* 태그 */
    .tw-tag-input { min-height: 44px; padding: 6px 10px; }
    #tw-tag-input { font-size: 13.5px; min-width: 96px; }
    .tw-tag-pill { height: 26px; font-size: 12px; }
    .tw-tag-suggest { gap: 4px; }
    .tw-tag-suggest-label { font-size: 10px; }
    .tw-tag-sug { height: 24px; font-size: 11.5px; padding: 0 8px; }

    /* 하단 액션 바 — 등록은 풀폭, 보조는 한 줄에 50:50 */
    .tw-actions {
      flex-wrap: wrap;
      gap: 8px;
      padding-top: 10px;
    }
    .tw-btn {
      height: 46px;
      padding: 0 14px;
      font-size: 14px;
    }
    .tw-btn--ghost,
    .tw-btn--outline { flex: 1; justify-content: center; }
    .tw-btn--primary {
      order: -1;
      width: 100%;
      padding: 0 20px;
      justify-content: center;
    }

    /* 토스트 — 모바일에선 하단 여백 줄임 */
    .tw-toast { bottom: 18px; padding: 10px 18px; font-size: 12.5px; }
  }

  /* 초소형 (≤ 480px) — 라디오/지역 1열 강제 */
  @media (max-width: 480px) {
    .tw-radio-row { grid-template-columns: 1fr; }
  }
  